3#ifndef PL_INCLUDING_BASICS_H
4# error "Please don't include TypeTraits.h directly, but instead include Foundation/Basics.h"
13 static constexpr int value = v;
20using plCompileTimeTrueType = char;
21using plCompileTimeFalseType = int;
27 using type = plCompileTimeFalseType;
33 using type = plCompileTimeTrueType;
38plCompileTimeFalseType operator%(
const T&,
const plTypeIsPod&);
42struct plIsPodType :
public plTraitInt<(sizeof(*((T*)0) % *((const plTypeIsPod*)0)) == sizeof(plCompileTimeTrueType)) ? 1 : 0>
53template <
typename T,
int N>
66 :
public plTraitInt<(sizeof(*((T*)0) % *((const plTypeIsMemRelocatable*)0)) == sizeof(plCompileTimeTrueType)) ? 2 : plIsPodType<T>::value>
71template <
typename From,
typename To>
74 static plCompileTimeTrueType Test(
const To&);
75 static plCompileTimeFalseType Test(...);
76 static From MakeFrom();
80 exists =
sizeof(Test(MakeFrom())) ==
sizeof(plCompileTimeTrueType),
97template <
typename T1,
typename T2>
103#ifdef __INTELLISENSE__
107# define PL_DECLARE_POD_TYPE()
114# define PL_DECLARE_MEM_RELOCATABLE_TYPE()
117# define PL_DECLARE_MEM_RELOCATABLE_TYPE_CONDITIONAL(T)
122# define PL_DETECT_TYPE_CLASS(...)
128# define PL_DECLARE_POD_TYPE() \
129 plCompileTimeTrueType operator%(const plTypeIsPod&) const \
139# define PL_DECLARE_MEM_RELOCATABLE_TYPE() \
140 plCompileTimeTrueType operator%(const plTypeIsMemRelocatable&) const \
146# define PL_DECLARE_MEM_RELOCATABLE_TYPE_CONDITIONAL(T) \
147 typename plConditionToCompileTimeBool<plGetTypeClass<T>::value == plTypeIsMemRelocatable::value || plIsPodType<T>::value>::type operator%( \
148 const plTypeIsMemRelocatable&) const \
153# define PL_DETECT_TYPE_CLASS_1(T1) plGetTypeClass<T1>
154# define PL_DETECT_TYPE_CLASS_2(T1, T2) plGetStrongestTypeClass<PL_DETECT_TYPE_CLASS_1(T1), PL_DETECT_TYPE_CLASS_1(T2)>
155# define PL_DETECT_TYPE_CLASS_3(T1, T2, T3) plGetStrongestTypeClass<PL_DETECT_TYPE_CLASS_2(T1, T2), PL_DETECT_TYPE_CLASS_1(T3)>
156# define PL_DETECT_TYPE_CLASS_4(T1, T2, T3, T4) plGetStrongestTypeClass<PL_DETECT_TYPE_CLASS_2(T1, T2), PL_DETECT_TYPE_CLASS_2(T3, T4)>
157# define PL_DETECT_TYPE_CLASS_5(T1, T2, T3, T4, T5) plGetStrongestTypeClass<PL_DETECT_TYPE_CLASS_4(T1, T2, T3, T4), PL_DETECT_TYPE_CLASS_1(T5)>
158# define PL_DETECT_TYPE_CLASS_6(T1, T2, T3, T4, T5, T6) \
159 plGetStrongestTypeClass<PL_DETECT_TYPE_CLASS_4(T1, T2, T3, T4), PL_DETECT_TYPE_CLASS_2(T5, T6)>
164# define PL_DETECT_TYPE_CLASS(...) \
165 plCompileTimeTrueType operator%( \
166 const plTraitInt<PL_CALL_MACRO(PL_PP_CONCAT(PL_DETECT_TYPE_CLASS_, PL_VA_NUM_ARGS(__VA_ARGS__)), (__VA_ARGS__))::value>&) const \
174#define PL_DEFINE_AS_POD_TYPE(T) \
176 struct plIsPodType<T> : public plTypeIsPod \
180PL_DEFINE_AS_POD_TYPE(
bool);
181PL_DEFINE_AS_POD_TYPE(
float);
182PL_DEFINE_AS_POD_TYPE(
double);
184PL_DEFINE_AS_POD_TYPE(
char);
185PL_DEFINE_AS_POD_TYPE(plInt8);
186PL_DEFINE_AS_POD_TYPE(plInt16);
187PL_DEFINE_AS_POD_TYPE(plInt32);
188PL_DEFINE_AS_POD_TYPE(plInt64);
189PL_DEFINE_AS_POD_TYPE(plUInt8);
190PL_DEFINE_AS_POD_TYPE(plUInt16);
191PL_DEFINE_AS_POD_TYPE(plUInt32);
192PL_DEFINE_AS_POD_TYPE(plUInt64);
193PL_DEFINE_AS_POD_TYPE(
wchar_t);
194PL_DEFINE_AS_POD_TYPE(
unsigned long);
195PL_DEFINE_AS_POD_TYPE(
long);
196PL_DEFINE_AS_POD_TYPE(std::byte);
199#define PL_IS_DERIVED_FROM_STATIC(BaseClass, DerivedClass) \
200 (plConversionTest<const DerivedClass*, const BaseClass*>::exists && !plConversionTest<const BaseClass*, const void*>::sameType)
203#define PL_IS_SAME_TYPE(TypeA, TypeB) plConversionTest<TypeA, TypeB>::sameType
230#define PL_MAKE_MEMBERFUNCTION_CHECKER(functionName, checkerName) \
231 template <typename T, typename Signature> \
234 template <typename U, U> \
236 template <typename O> \
237 static plCompileTimeTrueType& chk(type_check<Signature, &O::functionName>*); \
238 template <typename> \
239 static plCompileTimeFalseType& chk(...); \
242 value = (sizeof(chk<T>(0)) == sizeof(plCompileTimeTrueType)) ? 1 : 0 \
Converts a bool condition to CompileTimeTrue/FalseType.
Definition TypeTraits.h:26
Static Conversion Test.
Definition TypeTraits.h:73
Definition TypeTraits.h:99
If there is an % operator which takes a plTypeIsMemRelocatable and returns a CompileTimeTrueType T is...
Definition TypeTraits.h:67
If there is an % operator which takes a TypeIsPod and returns a CompileTimeTrueType T is Pod....
Definition TypeTraits.h:43
Type traits.
Definition TypeTraits.h:12
Definition TypeTraits.h:207
typename std::remove_const< typename std::remove_reference< T >::type >::type NonConstReferenceType
removes reference and const qualifier
Definition TypeTraits.h:218
typename std::remove_const< typename std::remove_reference< typename std::remove_pointer< T >::type >::type >::type NonConstReferencePointerType
removes reference, const and pointer qualifier Note that this removes the const and reference of the ...
Definition TypeTraits.h:225
typename std::remove_const< T >::type NonConstType
removes const qualifier
Definition TypeTraits.h:209
typename std::remove_pointer< T >::type NonPointerType
removes pointer
Definition TypeTraits.h:215
typename std::remove_pointer< typename std::remove_reference< T >::type >::type NonReferencePointerType
removes reference and pointer qualifier
Definition TypeTraits.h:221
typename std::remove_reference< T >::type NonReferenceType
removes reference
Definition TypeTraits.h:212