27template<
bool flag,
typename T,
typename F >
34template<
typename T,
typename F >
35class Select< false, T, F >
43template<
typename T,
typename U >
47 class B {
char dummy[2]; };
54 exists =
sizeof(test(make_T())) ==
sizeof(S),
55 two_way = exists && Conversion<U,T>::exists,
56 exists_2_way = two_way,
62class Conversion<void, void>
65 enum { exists = 1, two_way = 1, exists_2_way = two_way, same_type = 1 };
72 enum { exists = 1, two_way = 1, exists_2_way = two_way, same_type = 1 };
76class Conversion<void, T>
79 enum { exists = 0, two_way = 0, exists_2_way = two_way, same_type = 0 };
83class Conversion<T, void>
86 enum { exists = 0, two_way = 0, exists_2_way = two_way, same_type = 0 };
98 template<
typename U >
class Pointer_traits
101 typedef Null_type Pointee;
102 enum { value =
false };
105 template<
typename U >
class Pointer_traits< U* >
109 enum { value =
true };
112 template<
typename U >
struct Ref_traits
114 enum { value =
false };
118 template<
typename U >
struct Ref_traits<U&>
120 enum { value =
true };
125 template<
typename U >
struct Add_ref {
typedef U &Type; };
126 template<
typename U >
struct Add_ref<U&> {
typedef U Type; };
128 template<
typename U >
struct PMF_traits {
enum { value =
false }; };
129 template<
typename U,
typename F >
struct PMF_traits<U F::*>
130 {
enum { value =
true }; };
133 template<
typename U >
class Is_unsigned {
public:
enum { value =
false }; };
134 template<>
class Is_unsigned<unsigned> {
public:
enum { value =
true }; };
135 template<>
class Is_unsigned<unsigned char> {
136 public:
enum { value =
true };
138 template<>
class Is_unsigned<unsigned short> {
139 public:
enum { value =
true };
141 template<>
class Is_unsigned<unsigned long> {
142 public:
enum { value =
true };
144 template<>
class Is_unsigned<unsigned long long> {
145 public:
enum { value =
true };
148 template<
typename U >
class Is_signed {
public:
enum { value =
false }; };
149 template<>
class Is_signed<signed char> {
public:
enum { value =
true }; };
150 template<>
class Is_signed<signed short> {
public:
enum { value =
true }; };
151 template<>
class Is_signed<signed> {
public:
enum { value =
true }; };
152 template<>
class Is_signed<signed long> {
public:
enum { value =
true }; };
153 template<>
class Is_signed<signed long long> {
154 public:
enum { value =
true };
157 template<
typename U >
class Is_int {
public:
enum { value =
false }; };
158 template<>
class Is_int< char > {
public:
enum { value =
true }; };
159 template<>
class Is_int< bool > {
public:
enum { value =
true }; };
160 template<>
class Is_int< wchar_t > {
public:
enum { value =
true }; };
162 template<
typename U >
class Is_float {
public:
enum { value =
false }; };
163 template<>
class Is_float< float > {
public:
enum { value =
true }; };
164 template<>
class Is_float< double > {
public:
enum { value =
true }; };
165 template<>
class Is_float< long double > {
public:
enum { value =
true }; };
167 template<
typename T>
class Const_traits
170 enum { value =
false };
172 typedef const T Const_type;
175 template<
typename T>
class Const_traits<const T>
178 enum { value =
true };
180 typedef const T Const_type;
184template<
typename T >
191 is_unsigned = TT::Is_unsigned<T>::value,
192 is_signed = TT::Is_signed<T>::value,
193 is_int = TT::Is_int<T>::value,
194 is_float = TT::Is_float<T>::value,
195 is_pointer = TT::Pointer_traits<T>::value,
196 is_pointer_to_member = TT::PMF_traits<T>::value,
197 is_reference = TT::Ref_traits<T>::value,
198 is_scalar = is_unsigned || is_signed || is_int || is_pointer
199 || is_pointer_to_member || is_reference,
200 is_fundamental = is_unsigned || is_signed || is_float
201 || Conversion<T, void>::same_type,
202 is_const = TT::Const_traits<T>::value,
205 (
sizeof(T) >=
sizeof(
unsigned long)
206 ?
sizeof(
unsigned long)
207 : (sizeof(T) >= sizeof(unsigned)
209 : (sizeof(T) >= sizeof(short)
214 typedef typename Select<is_scalar, T, typename TT::Add_ref<typename TT::Const_traits<T>::Const_type>::Type>::Type Param_type;
215 typedef typename TT::Pointer_traits<T>::Pointee Pointee_type;
216 typedef typename TT::Ref_traits<T>::Referee Referee_type;
217 typedef typename TT::Const_traits<T>::Type Non_const_type;
218 typedef typename TT::Const_traits<T>::Const_type Const_type;
220 static unsigned long align(
unsigned long a)
222 return (a +
static_cast<unsigned long>(alignment) - 1UL)
223 & ~(
static_cast<unsigned long>(alignment) - 1UL);