Boost logo

Boost :

From: Jens Maurer (Jens.Maurer_at_[hidden])
Date: 2001-02-21 17:12:03

Daryle Walker wrote:
> The "char" type is supposed to be like either "signed char" or "unsigned
> char," which one is implementation defined. Similarly, the "wchar_t" type
> is supposed to be like one of the other integral types, which one is
> implementation defined. Could we have some sort of structure indicating
> those types' base types?

Please have a look at the newly updated boost/type_traits
You'd have to apply some compile-time-if magic (we don't seem to have
a template metaprogramming library yet).

numeric_limits<char>::is_signed helps you decide the signedness

In boost/integer.hpp, there's int_t<N>, so for usual 8bit chars,
int_t<sizeof(wchar_t)*8>::least may be another option (check
for signedness as with "char").

Anyway, for most of the more arcane template stuff, I'd rather
see an example why it's really useful, e.g. to know the type
underlying a "char" (you can always find out the signedness
with numeric_limits<char>::is_signed, that's not the point).

Jens Maurer

Boost list run by bdawes at, gregod at, cpdaniel at, john at