| 1 |
#ifndef INCLUDED_BASICTRAITS_H_ |
| 2 |
#define INCLUDED_BASICTRAITS_H_ |
| 3 |
|
| 4 |
template <typename TypeParam> |
| 5 |
class BasicTraits |
| 6 |
{ |
| 7 |
//BASIC |
| 8 |
template <typename T> |
| 9 |
struct Basic |
| 10 |
{ |
| 11 |
using Type = T; |
| 12 |
enum |
| 13 |
{ |
| 14 |
isPointer = false, |
| 15 |
isConst = false, |
| 16 |
isRef = false, |
| 17 |
isRRef = false |
| 18 |
}; |
| 19 |
}; |
| 20 |
//= |
| 21 |
template <typename T> |
| 22 |
struct Basic<T const> |
| 23 |
{ |
| 24 |
using Type = T; |
| 25 |
enum |
| 26 |
{ |
| 27 |
isPointer = true, |
| 28 |
isConst = true, |
| 29 |
isRef = false, |
| 30 |
isRRef = false |
| 31 |
}; |
| 32 |
}; |
| 33 |
//POINTER |
| 34 |
template <typename T> |
| 35 |
struct Basic<T *> |
| 36 |
{ |
| 37 |
using Type = T; |
| 38 |
enum |
| 39 |
{ |
| 40 |
isPointer = true, |
| 41 |
isConst = false, |
| 42 |
isRef = false, |
| 43 |
isRRef = false |
| 44 |
}; |
| 45 |
}; |
| 46 |
//= |
| 47 |
//CONST |
| 48 |
template <typename T> |
| 49 |
struct Basic<T const *> |
| 50 |
{ |
| 51 |
using Type = T; |
| 52 |
enum |
| 53 |
{ |
| 54 |
isPointer = true, |
| 55 |
isConst = true, |
| 56 |
isRef = false, |
| 57 |
isRRef = false |
| 58 |
}; |
| 59 |
}; |
| 60 |
//= |
| 61 |
template <typename T> |
| 62 |
struct Basic<T &> |
| 63 |
{ |
| 64 |
using Type = T; |
| 65 |
enum |
| 66 |
{ |
| 67 |
isPointer = false, |
| 68 |
isConst = false, |
| 69 |
isRef = true, |
| 70 |
isRRef = false |
| 71 |
}; |
| 72 |
}; |
| 73 |
|
| 74 |
template <typename T> |
| 75 |
struct Basic<T const &> |
| 76 |
{ |
| 77 |
using Type = T; |
| 78 |
enum |
| 79 |
{ |
| 80 |
isPointer = false, |
| 81 |
isConst = true, |
| 82 |
isRef = true, |
| 83 |
isRRef = false |
| 84 |
}; |
| 85 |
}; |
| 86 |
template <typename T> |
| 87 |
struct Basic<T &&> |
| 88 |
{ |
| 89 |
using Type = T; |
| 90 |
enum |
| 91 |
{ |
| 92 |
isPointer = false, |
| 93 |
isConst = false, |
| 94 |
isRef = false, |
| 95 |
isRRef = true |
| 96 |
}; |
| 97 |
}; |
| 98 |
template <typename T> |
| 99 |
struct Basic<T const &&> |
| 100 |
{ |
| 101 |
using Type = T; |
| 102 |
enum |
| 103 |
{ |
| 104 |
isPointer = false, |
| 105 |
isConst = true, |
| 106 |
isRef = false, |
| 107 |
isRRef = true |
| 108 |
}; |
| 109 |
}; |
| 110 |
|
| 111 |
public: |
| 112 |
BasicTraits(BasicTraits const &other) = delete; |
| 113 |
|
| 114 |
using ValueType = typename Basic<TypeParam>::Type; |
| 115 |
using PtrType = ValueType *; |
| 116 |
using RefType = ValueType &; |
| 117 |
using RvalueRefType = ValueType &&; |
| 118 |
|
| 119 |
enum |
| 120 |
{ |
| 121 |
isPointerType = Basic<TypeParam>::isPointer, |
| 122 |
isReferenceType = Basic<TypeParam>::isRef, |
| 123 |
isRvalueReferenceType = Basic<TypeParam>::isRRef, |
| 124 |
isConst = Basic<TypeParam>::isConst, |
| 125 |
|
| 126 |
isPlainType = not (isPointerType or isReferenceType or |
| 127 |
isRvalueReferenceType or isConst) |
| 128 |
}; |
| 129 |
|
| 130 |
}; |
| 131 |
|
| 132 |
#endif |