This is the mail archive of the mailing list for the libstdc++ project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Specializations of std::char_traits

On Tue, Jul 15, 2003 at 04:39:04PM -0700, Matt Austern wrote:
> We've received several complaints from customers who noticed that 
> std::char_traits<int> (or long, or signed char, or unsigned short, or 
> whatever) used to be defined but isn't defined anymore.
> Now, just to be obvious, I realize that
>  - The C++ standard doesn't say there should be any specializations 
> other than char and wchar_t
>  - In general there's no way to define all of the members of 
> std::char_traits for an arbitrary type.  There's no good way to say 
> what char_traits<T>::int_type should be, for example.

As I recall, the standard requires a default definition of
char_traits<T> for any T.  (I recall the vote in favor, which I 
opposed, if mildly.)  Therefore, there should be no need for
specializations for any but the char and wchar_t case.  Furthermore,
users are not allowed to specialize those, and the default
definitions are probably not right.  std::basic_string<int> should
work, but users should not expect to get std::filebuf<int> without

Users who need to define their own character types should use a struct
type they control, e.g. "struct MyChar { int c; };".

Nathan Myers

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]