Go Back   Rhinocerus > Newsgroup > Newsgroup comp.language.c++ > Newsgroup comp.language.c++.moderated

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 11-02-2005, 12:56 PM
Ai Azuma
Guest
 
Posts: n/a
Default Requirements on state type of std::codecvt

Hi,

I have a question about std::codecvt.
The standard says that std::codecvt is defined as follows,


namespace std{

template<class internT, class externT, class stateT>
class codecvt;

}


Then, what are the requirements on `stateT'? I looked at some
implemetations of the standard library, and they seem to require
`stateT' to be DefaultConstructible in order to construct an
initial state. But I would like to know precise descriptions of
the requirements on `stateT'. Could anyone help me?

Thanks in advance.


--
Ai Azuma


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Reply With Quote
Alt Today
Advertising
 
and become member of Rhinocerus
Standard Sponsored Links

  #2 (permalink)  
Old 11-03-2005, 11:59 AM
Ulrich Eckhardt
Guest
 
Posts: n/a
Default Re: Requirements on state type of std::codecvt

Ai Azuma wrote:
> I have a question about std::codecvt.
> The standard says that std::codecvt is defined as follows,
>
> template<class internT, class externT, class stateT>
> class codecvt;
>
> Then, what are the requirements on `stateT'? I looked at some
> implemetations of the standard library, and they seem to require
> `stateT' to be DefaultConstructible in order to construct an
> initial state. But I would like to know precise descriptions of
> the requirements on `stateT'.


There aren't any, AFAICT. For most codecvt facets (like codepages or the
UTF/UCS encodings), this parameter is in fact not used at all because they
are stateless. There are other encodings like Shift-JIS (if I remember
right, [1] had an example with it) where you can switch between different
character tables with escape sequences. In that case, this additional
context (the current character table) is recorded in this state_type.

For fstreams, this state_type is usually mbstate_t of the C API (or is it
POSIX?), which is part of the C multibyte character handling API. In most
implementations I have seen this was just an integer, only in newer GCC
iostreams this contains a structure which iconv (GNU's swiss chainsaw for
encoding conversion) uses for its state.

BTW: another requirement of state_type is that it is copyable, because the
fileposition type contains the offset into the file and this context.
Overall, I'd treat it like any other data type, but not necessarily a POD.

Uli

[1] "C++ IOStreams and Locales" by Langer and Kreft - the book to read when
you're interested in streams.


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Reply With Quote
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: A question on combine datasets toby dunn Newsgroup comp.soft-sys.sas 0 05-14-2006 11:35 PM
A question on combine datasets xxu8810152@gmail.com Newsgroup comp.soft-sys.sas 0 05-14-2006 11:15 PM
Re: set with 2 databases Ian Whitlock Newsgroup comp.soft-sys.sas 0 12-09-2005 05:18 PM
Re: Type I-IV Sum of squares with empty cells baogong jiang Newsgroup comp.soft-sys.sas 0 05-19-2005 03:35 PM
Re: Type I-IV Sum of squares with empty cells Robin High Newsgroup comp.soft-sys.sas 1 05-18-2005 03:56 AM



All times are GMT. The time now is 07:11 AM.


Copyright ©2009

LinkBacks Enabled by vBSEO 3.3.0 RC2 © 2009, Crawlability, Inc.