31#ifndef Pt_TypeTraits_h
32#define Pt_TypeTraits_h
39template <
typename T, T V>
40struct IntegralConstant
42 static const T value = V;
44 typedef IntegralConstant<T, V> Type;
46 operator ValueType()
const
52using BoolConstant = IntegralConstant<bool, V>;
54typedef BoolConstant<false> FalseType;
55typedef BoolConstant<true> TrueType;
58template<
class T,
class U>
59struct IsSame : FalseType
64struct IsSame<T, T> : TrueType
68template <
bool Condition,
typename TrueT,
typename FalseT>
75template <
typename TrueT,
typename FalseT>
76struct IfElse<false, TrueT, FalseT>
82template <std::size_t Index,
typename T,
typename... Ts>
85 typedef typename NthType<Index - 1, Ts...>::type type;
89template <
typename T,
typename... Ts>
90struct NthType<0, T, Ts...>
100 typedef const T ConstValue;
101 typedef T& Reference;
102 typedef const T& ConstReference;
104 typedef const T* ConstPointer;
112 static const unsigned int isConst = 0;
121struct TypeTraits<const T> :
public TypeTraitsBase<T>
123 static const unsigned int isConst = 1;
130struct TypeTraits<volatile T> :
public TypeTraitsBase<T>
132 static const unsigned int isConst = 0;
139struct TypeTraits<const volatile T> :
public TypeTraitsBase<T>
141 static const unsigned int isConst = 1;
149struct TypeTraits<T&> :
public TypeTraitsBase<T>
151 static const unsigned int isConst = 0;
152 static const unsigned int isVolatile = 0;
153 static const unsigned int isPointer = 0;
154 static const unsigned int isReference = 1;
159struct TypeTraits<const T&> :
public TypeTraitsBase<T>
161 static const unsigned int isConst = 1;
162 static const unsigned int isVolatile = 0;
163 static const unsigned int isPointer = 0;
164 static const unsigned int isReference = 1;
169struct TypeTraits<volatile T&> :
public TypeTraitsBase<T>
171 static const unsigned int isConst = 0;
172 static const unsigned int isVolatile = 1;
173 static const unsigned int isPointer = 0;
174 static const unsigned int isReference = 1;
179struct TypeTraits<const volatile T&> :
public TypeTraitsBase<T>
181 static const unsigned int isConst = 1;
182 static const unsigned int isVolatile = 1;
183 static const unsigned int isPointer = 0;
184 static const unsigned int isReference = 1;
189struct TypeTraits<T*> :
public TypeTraitsBase<T>
191 static const unsigned int isConst = 0;
192 static const unsigned int isVolatile = 0;
193 static const unsigned int isPointer = 1;
194 static const unsigned int isReference = 0;
199struct TypeTraits<const T*> :
public TypeTraitsBase<T>
201 static const unsigned int isConst = 1;
202 static const unsigned int isVolatile = 0;
203 static const unsigned int isPointer = 1;
204 static const unsigned int isReference = 0;
209struct TypeTraits<volatile T*> :
public TypeTraitsBase<T>
211 static const unsigned int isConst = 0;
212 static const unsigned int isVolatile = 1;
213 static const unsigned int isPointer = 1;
214 static const unsigned int isReference = 0;
219struct TypeTraits<const volatile T*> :
public TypeTraitsBase<T>
221 static const unsigned int isConst = 1;
222 static const unsigned int isVolatile = 1;
223 static const unsigned int isPointer = 1;
224 static const unsigned int isReference = 0;
228template <
typename T, std::
size_t N>
229struct TypeTraits<T[N]> :
public TypeTraitsBase<T*>
231 static const unsigned int isConst = 0;
238template <
typename T, std::
size_t N>
239struct TypeTraits<const T[N]> :
public TypeTraitsBase<const T*>
241 static const unsigned int isConst = 1;
248template <
typename T, std::
size_t N>
249struct TypeTraits<volatile T[N]> :
public TypeTraitsBase<volatile T*>
251 static const unsigned int isConst = 0;
258template <
typename T, std::
size_t N>
259struct TypeTraits<const volatile T[N]> :
public TypeTraitsBase<const volatile T*>
261 static const unsigned int isConst = 1;
269struct TypeTraits<T[]> :
public TypeTraitsBase<T*>
271 static const unsigned int isConst = 0;
279struct TypeTraits<const T[]> :
public TypeTraitsBase<const T*>
281 static const unsigned int isConst = 1;
289struct TypeTraits<volatile T[]> :
public TypeTraitsBase<volatile T*>
291 static const unsigned int isConst = 0;
299struct TypeTraits<const volatile T[]> :
public TypeTraitsBase<const volatile T*>
301 static const unsigned int isConst = 1;
308template <
typename R,
typename... Args>
309struct TypeTraits<R(*)(Args...)> :
public TypeTraitsBase<R(*)(Args...)>
311 static const unsigned int isConst = 0;
312 static const unsigned int isVolatile = 0;
313 static const unsigned int isPointer = 1;
314 static const unsigned int isReference = 0;
318template <
typename R,
typename... Args>
319struct TypeTraits<R(Args...)> :
public TypeTraitsBase<R(*)(Args...)>
321 static const unsigned int isConst = 0;
328template <
typename R,
typename... Args>
329struct TypeTraits<R(&)(Args...)> :
public TypeTraitsBase<R(*)(Args...)>
331 static const unsigned int isConst = 0;
332 static const unsigned int isVolatile = 0;
333 static const unsigned int isPointer = 0;
334 static const unsigned int isReference = 1;
342 typedef void ConstType;
348 static const unsigned int isConst = 0;
355template <
typename Base,
typename Derived>
356class IsCompatibleImpl
372 static YesType test(BaseType*);
373 static NoType test(...);
378 value =
sizeof(test(
static_cast<DerivedType*
>(0))) ==
sizeof(YesType)
383template <
typename Base,
typename Derived>
385:
public BoolConstant< IsCompatibleImpl<Base, Derived>::value >
394struct IntTraits<signed char>
396 typedef unsigned char Unsigned;
397 typedef signed char Signed;
399 static const unsigned int isSigned = 1;
403struct IntTraits<unsigned char>
405 typedef unsigned char Unsigned;
406 typedef signed char Signed;
408 static const unsigned int isSigned = 0;
412struct IntTraits<short>
414 typedef unsigned short Unsigned;
415 typedef signed short Signed;
417 static const unsigned int isSigned = 1;
421struct IntTraits<unsigned short>
423 typedef unsigned short Unsigned;
424 typedef signed short Signed;
426 static const unsigned int isSigned = 0;
432 typedef unsigned int Unsigned;
433 typedef signed int Signed;
435 static const unsigned int isSigned = 1;
439struct IntTraits<unsigned int>
441 typedef unsigned int Unsigned;
442 typedef signed int Signed;
444 static const unsigned int isSigned = 0;
448struct IntTraits<long>
450 typedef unsigned long Unsigned;
451 typedef signed long Signed;
453 static const unsigned int isSigned = 1;
457struct IntTraits<unsigned long>
459 typedef unsigned long Unsigned;
460 typedef signed long Signed;
462 static const unsigned int isSigned = 0;
466struct IntTraits<long long>
468 typedef unsigned long long Unsigned;
469 typedef signed long long Signed;
471 static const unsigned int isSigned = 1;
475struct IntTraits<unsigned long long>
477 typedef unsigned long long Unsigned;
478 typedef signed long long Signed;
480 static const unsigned int isSigned = 0;
Core module.
Definition Allocator.h:33
Traits for type properties.
Definition Api-TypeTraits.h:38
static const unsigned int isReference
If the type is a reference 1, otherwise 0.
Definition Api-TypeTraits.h:67
IMPLEMENTATION_DEFINED Pointer
The derived pointer type.
Definition Api-TypeTraits.h:52
static const unsigned int isConst
If the type is const 1, otherwise 0.
Definition Api-TypeTraits.h:58
IMPLEMENTATION_DEFINED ConstReference
The derived const qualified reference type.
Definition Api-TypeTraits.h:49
IMPLEMENTATION_DEFINED ConstPointer
The derived const qualified reference type.
Definition Api-TypeTraits.h:55
static const unsigned int isPointer
If the type is a pointer 1, otherwise 0.
Definition Api-TypeTraits.h:64
IMPLEMENTATION_DEFINED Reference
The derived reference type.
Definition Api-TypeTraits.h:46
static const unsigned int isVolatile
If the type is volatile 1, otherwise 0.
Definition Api-TypeTraits.h:61
IMPLEMENTATION_DEFINED Value
The derived value type.
Definition Api-TypeTraits.h:40