ezEngine  Milestone 9
TypeTraits.h File Reference
#include <Foundation/Basics.h>

Go to the source code of this file.

Classes

struct  ezTraitInt< v >
 Type traits. More...
 
struct  ezIsPodType< T >
 If there is an % operator which takes a TypeIsPod and returns a CompileTimeTrueType T is Pod. Default % operator return false. More...
 
struct  ezIsPodType< T * >
 Pointers are POD types. More...
 
struct  ezIsPodType< T[N]>
 arrays are POD types More...
 
struct  ezGetTypeClass< T >
 If there is an % operator which takes a ezTypeIsMemRelocatable and returns a CompileTimeTrueType T is Pod. Default % operator return false. More...
 
struct  ezConversionTest< From, To >
 Static Conversion Test. More...
 
struct  ezConversionTest< T, T >
 Specialization for above Type. More...
 
struct  ezGetStrongestTypeClass< T1, T2 >
 
struct  ezIsPointer< T >
 Determines whether a type is a pointer. More...
 
struct  ezIsPointer< T * >
 
struct  ezTypeTraits< T >
 

Macros

#define EZ_DECLARE_POD_TYPE()   ezCompileTimeTrueType operator%(const ezTypeIsPod&) const
 Embed this into a class to mark it as a POD type. POD types will get special treatment from allocators and container classes, such that they are faster to construct and copy.
 
#define EZ_DECLARE_MEM_RELOCATABLE_TYPE()   ezCompileTimeTrueType operator%(const ezTypeIsMemRelocatable&) const
 Embed this into a class to mark it as memory relocatable. Memory relocatable types will get special treatment from allocators and container classes, such that they are faster to construct and copy. A type is memory relocatable if it does not have any internal references. e.g: struct example { char[16] buffer; char* pCur; example() pCur(buffer) {} }; A memory relocatable type also must not give out any pointers to its own location. If these two conditions are met, a type is memory relocatable.
 
#define EZ_DETECT_TYPE_CLASS_1(T1)   ezGetTypeClass<T1>
 
#define EZ_DETECT_TYPE_CLASS_2(T1, T2)   ezGetStrongestTypeClass<EZ_DETECT_TYPE_CLASS_1(T1), EZ_DETECT_TYPE_CLASS_1(T2)>
 
#define EZ_DETECT_TYPE_CLASS_3(T1, T2, T3)   ezGetStrongestTypeClass<EZ_DETECT_TYPE_CLASS_2(T1, T2), EZ_DETECT_TYPE_CLASS_1(T3)>
 
#define EZ_DETECT_TYPE_CLASS_4(T1, T2, T3, T4)   ezGetStrongestTypeClass<EZ_DETECT_TYPE_CLASS_2(T1, T2), EZ_DETECT_TYPE_CLASS_2(T3, T4)>
 
#define EZ_DETECT_TYPE_CLASS_5(T1, T2, T3, T4, T5)   ezGetStrongestTypeClass<EZ_DETECT_TYPE_CLASS_4(T1, T2, T3, T4), EZ_DETECT_TYPE_CLASS_1(T5)>
 
#define EZ_DETECT_TYPE_CLASS_6(T1, T2, T3, T4, T5, T6)   ezGetStrongestTypeClass<EZ_DETECT_TYPE_CLASS_4(T1, T2, T3, T4), EZ_DETECT_TYPE_CLASS_2(T5, T6)>
 
#define EZ_DETECT_TYPE_CLASS(...)
 
#define EZ_DEFINE_AS_POD_TYPE(T)
 Defines a type T as Pod. POD types will get special treatment from allocators and container classes, such that they are faster to construct and copy. More...
 
#define EZ_IS_DERIVED_FROM_STATIC(BaseClass, DerivedClass)   (ezConversionTest<const DerivedClass*, const BaseClass*>::exists && !ezConversionTest<const BaseClass*, const void*>::sameType)
 Checks inheritance at compile time.
 
#define EZ_IS_SAME_TYPE(TypeA, TypeB)   ezConversionTest<TypeA, TypeB>::sameType
 Checks whether A and B are the same type.
 
#define EZ_MAKE_MEMBERFUNCTION_CHECKER(functionName, checkerName)
 

Typedefs

typedef ezTraitInt< 2 > ezTypeIsMemRelocatable
 
typedef ezTraitInt< 1 > ezTypeIsPod
 
typedef ezTraitInt< 0 > ezTypeIsClass
 
typedef char ezCompileTimeTrueType
 
typedef int ezCompileTimeFalseType
 

Functions

template<typename T >
ezCompileTimeFalseType operator% (const T &, const ezTypeIsPod &)
 Default % operator for T and TypeIsPod which returns a CompileTimeFalseType.
 
template<typename T >
ezCompileTimeFalseType operator% (const T &, const ezTypeIsMemRelocatable &)
 Default % operator for T and ezTypeIsMemRelocatable which returns a CompileTimeFalseType.
 
 EZ_DEFINE_AS_POD_TYPE (bool)
 
 EZ_DEFINE_AS_POD_TYPE (float)
 
 EZ_DEFINE_AS_POD_TYPE (double)
 
 EZ_DEFINE_AS_POD_TYPE (ezInt8)
 
 EZ_DEFINE_AS_POD_TYPE (ezInt16)
 
 EZ_DEFINE_AS_POD_TYPE (ezInt32)
 
 EZ_DEFINE_AS_POD_TYPE (ezInt64)
 
 EZ_DEFINE_AS_POD_TYPE (ezUInt8)
 
 EZ_DEFINE_AS_POD_TYPE (ezUInt16)
 
 EZ_DEFINE_AS_POD_TYPE (ezUInt32)
 
 EZ_DEFINE_AS_POD_TYPE (ezUInt64)
 
 EZ_DEFINE_AS_POD_TYPE (wchar_t)
 

Macro Definition Documentation

◆ EZ_DEFINE_AS_POD_TYPE

#define EZ_DEFINE_AS_POD_TYPE (   T)
Value:
template <> \
struct ezIsPodType<T> : public ezTypeIsPod \
{ \
}
Type traits.
Definition: TypeTraits.h:9
If there is an % operator which takes a TypeIsPod and returns a CompileTimeTrueType T is Pod...
Definition: TypeTraits.h:30

Defines a type T as Pod. POD types will get special treatment from allocators and container classes, such that they are faster to construct and copy.

◆ EZ_DETECT_TYPE_CLASS

#define EZ_DETECT_TYPE_CLASS (   ...)
Value:
ezCompileTimeTrueType operator%( \
const ezTraitInt<EZ_CALL_MACRO(EZ_CONCAT(EZ_DETECT_TYPE_CLASS_, EZ_VA_NUM_ARGS(__VA_ARGS__)), (__VA_ARGS__))::value>&) const
ezCompileTimeFalseType operator%(const T &, const ezTypeIsPod &)
Default % operator for T and TypeIsPod which returns a CompileTimeFalseType.
Type traits.
Definition: TypeTraits.h:9
#define EZ_CONCAT(x, y)
Concatenates two strings, even when the strings are macros themselves.
Definition: PreprocessorUtils.h:7

◆ EZ_MAKE_MEMBERFUNCTION_CHECKER

#define EZ_MAKE_MEMBERFUNCTION_CHECKER (   functionName,
  checkerName 
)
Value:
template <typename T, typename Signature> \
struct checkerName \
{ \
template <typename U, U> \
struct type_check; \
template <typename O> \
static ezCompileTimeTrueType& chk(type_check<Signature, &O::functionName>*); \
template <typename> \
static ezCompileTimeFalseType& chk(...); \
enum \
{ \
value = (sizeof(chk<T>(0)) == sizeof(ezCompileTimeTrueType)) ? 1 : 0 \
}; \
}

generates a template named 'checkerName' which checks for the existence of a member function with the name 'functionName' and the signature 'Signature'