Re: [boost] Traits for character underlying types
by Jens Maurer other posts by this author
Feb 21 2001 10:12PM messages near this date
Traits for character underlying types
|
[boost] Recover MSVC auto-complete with smart pointers?
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
issue
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
Thread:
Daryle Walker
Jens Maurer
|