ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> boost
boost
Traits for character underlying types
by Daryle Walker other posts by this author
Feb 20 2001 7:48PM messages near this date
Where's this convenient macro? (was: Re: type_traits again) | Re: [boost] Traits for character underlying types
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
Thread:
Daryle Walker
Jens Maurer

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved