|
|||
|
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! ] |
|
|
||||
|
||||
|
|
|
|||
|
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! ] |
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
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 |