Benjamin Kosnik - Re: user-defined types and basic_string (original) (raw)
This is the mail archive of the libstdc++@gcc.gnu.orgmailing 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] |
- From: Benjamin Kosnik
- To: Gabriel Dos Reis
- Cc: libstdc++ at gcc dot gnu dot org
- Date: Fri, 23 Aug 2002 11🔞14 -0700
- Subject: Re: user-defined types and basic_string
- Organization: Red Hat / San Francisco
- References: <200208231731.g7NHV7Q02241@fillmore.constant.com><m37kihv4eq.fsf@soliton.integrable-solutions.net>
User-defined constructors are not permitted in PODs. I think we don't really need the conversion function. To the above should just read
struct character { unsigned short value; };
Or, I think we could just put in a template surrogate for fundamental types:
template struct character { T value; };
along with the two functions:
template inline bool operator==(character lhs, character rhs) { return lhs.value == rhs.value; }
template inline bool operator<(character lhs, character rhs) { return lhs.value < rhs.value; }
Cool. I stand corrected.
| // NB: this type should be bigger than char_type, so as to | // properly hold EOF values in addition to the full range of | // char_type values. | typedef unsigned long int_type;
This makes the assumption that range(unsigned long) is a strict superset of range(unsigned short). If we were going to assume that, why not just use "int" as int_type?
Could do. (Unsigned int though if value_type == unsigned short, oui?)
It seems int_type is one of the points where the generic templates start to fall down...
From your yesterday mail, I thought you were talking of a generic way to define customization points of char_traits for users.
Actually, I'm not convinced that we should make a big deal about defining a specialization for std::char_traits<>. Defining such a specialization just amonts to define a trait class in one's own namespace, but then there is no need to wrap the fundamental types in a struct. Thoughts?
I'm not quite sure I follow you. Can you give examples in C++?
-benjamin
- Follow-Ups:
- Re: user-defined types and basic_string
* From: Matt Austern - Re: user-defined types and basic_string
* From: Gabriel Dos Reis
- Re: user-defined types and basic_string
- References:
- user-defined types and basic_string
* From: Benjamin Kosnik - Re: user-defined types and basic_string
* From: Gabriel Dos Reis
- user-defined types and basic_string
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |