Specializations of std::char_traits
Gabriel Dos Reis
gdr@integrable-solutions.net
Thu Jul 17 17:00:00 GMT 2003
Matt Austern <austern@apple.com> writes:
| On Thursday, July 17, 2003, at 8:28AM, Gabriel Dos Reis wrote:
|
| > "B. Kosnik" <bkoz@nabi.net> writes:
| >
| > | > On the contrary, I think it does matter. int_type is supposed
| > to be
| > | > provided by char_traits<>. Nobody knows whether it is used by
| > users
| > | > only with iostreams. Either we provide something consistent or
| > we don't
| > | > provide a definition at all.
| > |
| > | Ditto for state_type. I don't see how a truly generic char_traits
| > can be
| > | done with one template parameter: I'd think (at least) three would be
| > | necessary.
| >
| > Yeah, I thought about that too -- based on your recent changes to
| > pod_char_traits. To be honest, I don't have any favorite (and I think
| > I can be convinced for one way or the other :-).
| > I also thought about using a decoupled external traits like
| >
| > template<typename CharT>
| > struct int_type {
| > // ...
| > };
| >
| > template<typename CharT>
| > struct state_type {
| > // ...
| > };
|
| I don't think it's worth it. In principle, the traits parameter *is*
| supposed to be
| the traits class saying what state_type and int_type are.
I suppose I didn't elaborate enough. Given the above declaration, the
main __gnu_cxx::char_traits is defined as :
template<typename CharT>
struct char_traits {
typedef typename __gnu_cxx::int_type<CharT>::type int_type;
typedef typename __gnu_cxx::state_type<CharT>::type state_type
// ...
};
char_traits still is the source that says what
char_traits<>::state_type is supposed to be: It just says so by looking
up a table. From user perspective, most of the functions might be
right, except a single or two types. The above just gives enough to
have the job done.
-- Gaby
More information about the Libstdc++
mailing list