|
Boost : |
From: Daryle Walker (darylew_at_[hidden])
Date: 2001-02-20 14:48:14
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? I guess it would be something like:
//==========================================================================
template <typename T> struct underlying_type;
template <>
struct underlying_type<char>
{
typedef something base_type;
};
// The following should be macro-blocked for compilers that don't have
// a separate "wchar_t" type.
template <>
struct underlying_type<wchar_t>
{
typedef something base_type;
};
// Should there be a general version of this template? If so, I guess that
// the those T types should map to themselves.
// We don't have to do class templates, maybe macro magic will do:
#if SOMETHING
typedef signed char char_underlying_type
#else
typedef unsigned char char_underlying_type
#endif
#if HAVE_INTRINSIC_WCHAR_T
#if SOMETHING
typedef signed char wchar_t_underlying_type
#elif SOMETHING_ELSE
typedef unsigned char wchar_t_underlying_type
//...
#else
typedef unsigned long long wchar_t_underlying_type
#endif
#endif
//==========================================================================
How would we figure out the types? I guess something using <climits> macros
and/or comparisons from <limits> values would be used. What header would
this go under, "type_traits.hpp" or a new one?
-- Daryle Walker Mac, Internet, and Video Game Junkie darylew AT mac DOT com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk