29 #ifndef Pt_TypeTraits_h
30 #define Pt_TypeTraits_h
37 template <
typename T, T V>
38 struct IntegralConstant
40 static const T value = V;
42 typedef IntegralConstant<T, V> Type;
44 operator ValueType()
const
50 using BoolConstant = IntegralConstant<bool, V>;
52 typedef BoolConstant<false> FalseType;
53 typedef BoolConstant<true> TrueType;
56 template<
class T,
class U>
57 struct IsSame : FalseType
62 struct IsSame<T, T> : TrueType
66 template <
bool Condition,
typename TrueT,
typename FalseT>
73 template <
typename TrueT,
typename FalseT>
74 struct IfElse<false, TrueT, FalseT>
84 typedef const T ConstValue;
86 typedef const T& ConstReference;
88 typedef const T* ConstPointer;
93 struct TypeTraits :
public TypeTraitsBase<T>
95 static const unsigned int isConst = 0;
101 template <
typename T>
102 struct TypeTraits<const T> :
public TypeTraitsBase<T>
104 static const unsigned int isConst = 1;
110 template <
typename T>
111 struct TypeTraits<T&> :
public TypeTraitsBase<T>
113 static const unsigned int isConst = 0;
114 static const unsigned int isPointer = 0;
115 static const unsigned int isReference = 1;
119 template <
typename T>
120 struct TypeTraits<const T&> :
public TypeTraitsBase<T>
122 static const unsigned int isConst = 1;
123 static const unsigned int isPointer = 0;
124 static const unsigned int isReference = 1;
128 template <
typename T>
129 struct TypeTraits<T*> :
public TypeTraitsBase<T>
131 static const unsigned int isConst = 0;
132 static const unsigned int isPointer = 1;
133 static const unsigned int isReference = 0;
137 template <
typename T>
138 struct TypeTraits<const T*> :
public TypeTraitsBase<T>
140 static const unsigned int isConst = 1;
141 static const unsigned int isPointer = 1;
142 static const unsigned int isReference = 0;
146 template <
typename T, std::
size_t N>
147 struct TypeTraits<T[N]> :
public TypeTraitsBase<T>
149 static const unsigned int isConst = 0;
156 struct TypeTraits<void>
159 typedef void ConstType;
165 static const unsigned int isConst = 0;
171 template <
typename Base,
typename Derived>
172 class IsCompatibleImpl
188 static YesType test(BaseType*);
189 static NoType test(...);
194 value =
sizeof(test(
static_cast<DerivedType*
>(0))) ==
sizeof(YesType)
199 template <
typename Base,
typename Derived>
201 :
public BoolConstant< IsCompatibleImpl<Base, Derived>::value >
205 template <
typename T>
210 struct IntTraits<signed char>
212 typedef unsigned char Unsigned;
213 typedef signed char Signed;
215 static const unsigned int isSigned = 1;
219 struct IntTraits<unsigned char>
221 typedef unsigned char Unsigned;
222 typedef signed char Signed;
224 static const unsigned int isSigned = 0;
228 struct IntTraits<short>
230 typedef unsigned short Unsigned;
231 typedef signed short Signed;
233 static const unsigned int isSigned = 1;
237 struct IntTraits<unsigned short>
239 typedef unsigned short Unsigned;
240 typedef signed short Signed;
242 static const unsigned int isSigned = 0;
246 struct IntTraits<int>
248 typedef unsigned int Unsigned;
249 typedef signed int Signed;
251 static const unsigned int isSigned = 1;
255 struct IntTraits<unsigned int>
257 typedef unsigned int Unsigned;
258 typedef signed int Signed;
260 static const unsigned int isSigned = 0;
264 struct IntTraits<long>
266 typedef unsigned long Unsigned;
267 typedef signed long Signed;
269 static const unsigned int isSigned = 1;
273 struct IntTraits<unsigned long>
275 typedef unsigned long Unsigned;
276 typedef signed long Signed;
278 static const unsigned int isSigned = 0;
282 struct IntTraits<long long>
284 typedef unsigned long long Unsigned;
285 typedef signed long long Signed;
287 static const unsigned int isSigned = 1;
291 struct IntTraits<unsigned long long>
293 typedef unsigned long long Unsigned;
294 typedef signed long long Signed;
296 static const unsigned int isSigned = 0;
301 #endif // Pt_TypeTraits_h
Core module.
Definition: pt-gfx-images.dox:14
static const unsigned int isReference
If the type is a reference 1, otherwise 0.
Definition: TypeTraits.h:45
IMPLEMENTATION_DEFINED ConstReference
The derived const qualified reference type.
Definition: TypeTraits.h:30
static const unsigned int isPointer
If the type is a pointer 1, otherwise 0.
Definition: TypeTraits.h:42
IMPLEMENTATION_DEFINED Pointer
The derived pointer type.
Definition: TypeTraits.h:33
IMPLEMENTATION_DEFINED Reference
The derived reference type.
Definition: TypeTraits.h:27
IMPLEMENTATION_DEFINED Value
The derived value type.
Definition: TypeTraits.h:21
IMPLEMENTATION_DEFINED ConstPointer
The derived const qualified reference type.
Definition: TypeTraits.h:36
static const unsigned int isConst
If the type is const 1, otherwise 0.
Definition: TypeTraits.h:39