I didn't implemented extended signed and extended unsigned. I didn't
integrate into the test driver.
template <class T, T v>
struct integral_constant
{
typedef T value_type;
static const value_type value = v;
typedef integral_constant<value_type, value> type;
};
template <class T, T v>
const typename integral_constant<T, v>::value_type
integral_constant<T, v>::
value;
typedef integral_constant<bool, true> true_type;
typedef integral_constant<bool, false> false_type;
template <class, class> struct is_same: false_type { };
template <class T> struct is_same<T, T>: true_type { };
// is T a standard signed/unsigned integer type?
template <class> struct __is_std_signed: false_type { };
template <class> struct __is_std_unsigned: false_type { };
// __is_std_signed specializations for each standard signed
template <>
struct __is_std_signed<const volatile signed char>:
true_type { };
template <>
struct __is_std_signed<const volatile signed int>:
true_type { };
template <>
struct __is_std_signed<const volatile signed short>:
true_type { };
template <>
struct __is_std_signed<const volatile signed long>:
true_type { };
template <>
struct __is_std_signed<const volatile signed long long>:
true_type { };
// __is_std_unsigned specializations for each standard unsigned
template <>
struct __is_std_unsigned<const volatile unsigned char>:
true_type { };
template <>
struct __is_std_unsigned<const volatile unsigned int>:
true_type { };
template <>
struct __is_std_unsigned<const volatile unsigned short>:
true_type { };
template <>
struct __is_std_unsigned<const volatile unsigned long>:
true_type { };
template <>
struct __is_std_unsigned<const volatile unsigned long long>:
true_type { };
// __is_ext_signed and __is_ext_unsigned traits for implementation
// defined extended signed and extended unsigned integer types
//template <class> struct __is_ext_signed: false_type { };
//template <class> struct __is_ext_unsigned: false_type { };
template <class T>
struct is_signed:
integral_constant<bool,
__is_std_signed<const volatile T>::value>
{ };
// || __is_ext_signed<const volatile T>::value>
template <class T>
struct is_unsigned:
integral_constant<bool,
__is_std_unsigned<const volatile T>::value>
{ };
// || __is_ext_unsigned<const volatile T>::value>
template <class T>
struct is_void:
integral_constant<
bool,
is_same<const volatile T, const volatile void>::value>
{ };
template <class T>
struct is_integral:
integral_constant<
bool,
is_signed<T>::value
|| is_unsigned<T>::value
|| is_same<const volatile T, const volatile bool>::value
|| is_same<const volatile T, const volatile char>::value
|| is_same<const volatile T, const volatile wchar_t>::value>
{ };
template <class T>
struct is_floating_point:
integral_constant<
bool,
is_same<const volatile T, const volatile float>::value
|| is_same<const volatile T, const volatile double>::value
|| is_same<const volatile T, const volatile long double>::value>
{ };
template <class T>
struct is_array: false_type { };
template <class T>
struct is_array<T[]>: true_type{ };
template <class T>
struct is_pointer: false_type { };
template <class T>
struct is_pointer<T*>: true_type{ };
template <class T>
struct is_reference: false_type { };
template <class T>
struct is_reference<T&>: true_type{ };
Yu (Scott) Zhong
Consulting Engineer
Rogue Wave Software, a Quovadxtm division
[EMAIL PROTECTED]
ph: 303 545 3182