6#ifndef _ZFI_ZFCoreUtilTemplate_h_
7#define _ZFI_ZFCoreUtilTemplate_h_
20template<
typename T_Type>
30 template<
typename T_Ref>
zftValue(
ZF_IN T_Ref
const &ref) : zfv(ref) {}
33 template<
typename T_Ref>
inline zftValue<T_Type> &operator = (
ZF_IN T_Ref
const &ref) {zfv = ref;
return *
this;}
34 inline operator T_Type
const & (void)
const {
return zfv;}
35 inline operator T_Type & (void) {
return zfv;}
52 _ZFP_zftType<void(__VA_ARGS__)>::Type
55template<
typename T_Ret,
typename T_Type>
76#define zftTraitsModifierName_N "N"
78#define zftTraitsModifierName_R "R"
80#define zftTraitsModifierName_CR "CR"
82#define zftTraitsModifierName_P "P"
84#define zftTraitsModifierName_PR "PR"
86#define zftTraitsModifierName_PCR "PCR"
88#define zftTraitsModifierName_CP "CP"
90#define zftTraitsModifierName_CPR "CPR"
92#define zftTraitsModifierName_CPCR "CPCR"
99template<
typename T_Type>
149template<
typename T_Type>
157 typedef T_Type TrType;
158 typedef T_Type & TrRef;
159 typedef T_Type
const & TrConstRef;
160 typedef T_Type * TrPtr;
161 typedef const T_Type * TrConstPtr;
162 typedef T_Type TrNoRef;
165template<
typename T_Type>
173 typedef T_Type TrType;
174 typedef T_Type & TrRef;
175 typedef T_Type
const & TrConstRef;
176 typedef T_Type * TrPtr;
177 typedef const T_Type * TrConstPtr;
178 typedef T_Type TrNoRef;
181template<
typename T_Type>
189 typedef T_Type TrType;
190 typedef T_Type & TrRef;
191 typedef T_Type
const & TrConstRef;
192 typedef T_Type * TrPtr;
193 typedef const T_Type * TrConstPtr;
194 typedef T_Type * TrNoRef;
197template<
typename T_Type>
205 typedef T_Type TrType;
206 typedef T_Type & TrRef;
207 typedef T_Type
const & TrConstRef;
208 typedef T_Type * TrPtr;
209 typedef const T_Type * TrConstPtr;
210 typedef T_Type * TrNoRef;
213template<
typename T_Type>
221 typedef T_Type TrType;
222 typedef T_Type & TrRef;
223 typedef T_Type
const & TrConstRef;
224 typedef T_Type * TrPtr;
225 typedef const T_Type * TrConstPtr;
226 typedef T_Type * TrNoRef;
229template<
typename T_Type>
237 typedef T_Type TrType;
238 typedef T_Type & TrRef;
239 typedef T_Type
const & TrConstRef;
240 typedef T_Type * TrPtr;
241 typedef const T_Type * TrConstPtr;
242 typedef const T_Type * TrNoRef;
245template<
typename T_Type>
253 typedef T_Type TrType;
254 typedef T_Type & TrRef;
255 typedef T_Type
const & TrConstRef;
256 typedef T_Type * TrPtr;
257 typedef const T_Type * TrConstPtr;
258 typedef const T_Type * TrNoRef;
261template<
typename T_Type>
269 typedef T_Type TrType;
270 typedef T_Type & TrRef;
271 typedef T_Type
const & TrConstRef;
272 typedef T_Type * TrPtr;
273 typedef const T_Type * TrConstPtr;
274 typedef const T_Type * TrNoRef;
288 typedef void TrConstRef;
289 typedef void * TrPtr;
290 typedef const void * TrConstPtr;
291 typedef void TrNoRef;
302 typedef const void TrType;
303 typedef const void TrRef;
304 typedef const void TrConstRef;
305 typedef const void * TrPtr;
306 typedef const void * TrConstPtr;
307 typedef const void TrNoRef;
320 typedef void *
const & TrConstRef;
321 typedef void * TrPtr;
322 typedef const void * TrConstPtr;
323 typedef void * TrNoRef;
336 typedef const void *
const & TrConstRef;
337 typedef void * TrPtr;
338 typedef const void * TrConstPtr;
339 typedef const void * TrNoRef;
352 typedef void *
const & TrConstRef;
353 typedef void * TrPtr;
354 typedef const void * TrConstPtr;
355 typedef void * TrNoRef;
368 typedef void *
const & TrConstRef;
369 typedef void * TrPtr;
370 typedef const void * TrConstPtr;
371 typedef void * TrNoRef;
384 typedef void *
const & TrConstRef;
385 typedef void * TrPtr;
386 typedef const void * TrConstPtr;
387 typedef const void * TrNoRef;
400 typedef void *
const & TrConstRef;
401 typedef void * TrPtr;
402 typedef const void * TrConstPtr;
403 typedef const void * TrNoRef;
410template<
int cond = 0,
typename T_Fix =
void>
423template<
typename T0,
typename T1>
447 static char _test(
int U::*);
449 static int _test(...);
453 Value = ((
sizeof(_test<T>(0)) ==
sizeof(char)) ? 1 : 0)
459template<
typename TChild,
typename TBase,
463 template<
typename T_Dummy>
464 static char _test(TChild
const &, T_Dummy);
465 static int _test(TBase
const &,
int);
468 operator TChild
const & (void);
469 operator TBase
const & (void)
const;
474 Value = ((
sizeof(_test(_Conv(), 0)) ==
sizeof(char)) ? 1 : 0)
478template<
typename TChild,
typename TBase>
498template<
typename T_Type>
508template<
typename T_Type>
517template<
typename T_Type>
522#define ZFHASH_DECLARE(Type, action) \
525 zfclassNotPOD zftHash<Type > { \
527 static zfidentity value(ZF_IN const Type &v) { \
533#define ZFHASH_DECLARE_TEMPLATE(T_Type, Type, action) \
536 zfclassNotPOD zftHash<Type > { \
538 static zfidentity value(ZF_IN const Type &v) { \
547template<
typename T_Element>
549 ZF_IN T_Element
const &v0
550 ,
ZF_IN T_Element
const &v1
552 return zfmemcmp(&v0, &v1,
sizeof(T_Element));
556#define ZFCORE_POD_DECLARE(Type) \
557 _ZFP_ZFCORE_POD_DECLARE(template<>, _ZFP_ZFCORE_POD_DECLARE_EXPAND(Type)) \
558 _ZFP_ZFCORE_POD_DECLARE_COMPARER(_ZFP_ZFCORE_POD_DECLARE_EMPTY(), _ZFP_ZFCORE_POD_DECLARE_EXPAND(Type))
560#define ZFCORE_POD_DECLARE_TEMPLATE(T_Type, Type) \
561 _ZFP_ZFCORE_POD_DECLARE(_ZFP_ZFCORE_POD_DECLARE_EXPAND(template< T_Type >),_ZFP_ZFCORE_POD_DECLARE_EXPAND(Type)) \
562 _ZFP_ZFCORE_POD_DECLARE_COMPARER(_ZFP_ZFCORE_POD_DECLARE_EXPAND(template< T_Type >), _ZFP_ZFCORE_POD_DECLARE_EXPAND(Type))
565#define ZFCORE_POD_DECLARE_NO_COMPARER(Type) \
566 _ZFP_ZFCORE_POD_DECLARE(template<>,_ZFP_ZFCORE_POD_DECLARE_EXPAND(Type))
568#define ZFCORE_POD_DECLARE_TEMPLATE_NO_COMPARER(T_Type, Type) \
569 _ZFP_ZFCORE_POD_DECLARE(_ZFP_ZFCORE_POD_DECLARE_EXPAND(template< T_Type >),_ZFP_ZFCORE_POD_DECLARE_EXPAND(Type))
571#define _ZFP_ZFCORE_POD_DECLARE_EMPTY(...)
572#define _ZFP_ZFCORE_POD_DECLARE_EXPAND(...) __VA_ARGS__
573#define _ZFP_ZFCORE_POD_DECLARE(classFix, Type) \
576 zfclassNotPOD zftIsPOD<Type > { \
583 zfclassNotPOD zftHash<Type > { \
585 static zfidentity value(ZF_IN const Type &v) { \
586 return zfidentityCalc(v); \
590#define _ZFP_ZFCORE_POD_DECLARE_COMPARER(funcFix, Type) \
592 funcFix inline zfbool operator == (ZF_IN const Type &v0, ZF_IN const Type &v1) {return zfcmpPOD(v0, v1) == 0;} \
593 funcFix inline zfbool operator != (ZF_IN const Type &v0, ZF_IN const Type &v1) {return zfcmpPOD(v0, v1) != 0;} \
594 funcFix inline zfbool operator < (ZF_IN const Type &v0, ZF_IN const Type &v1) {return zfcmpPOD(v0, v1) < 0;} \
595 funcFix inline zfbool operator <= (ZF_IN const Type &v0, ZF_IN const Type &v1) {return zfcmpPOD(v0, v1) <= 0;} \
596 funcFix inline zfbool operator > (ZF_IN const Type &v0, ZF_IN const Type &v1) {return zfcmpPOD(v0, v1) > 0;} \
597 funcFix inline zfbool operator >= (ZF_IN const Type &v0, ZF_IN const Type &v1) {return zfcmpPOD(v0, v1) >= 0;} \
_ZFT_t_zfchar zfchar
char wrapper
Definition ZFCoreTypeDef_CharType.h:17
#define zfclassLikePOD
shows the class is not a POD type, but you may use it like a POD except memset it to 0
Definition ZFCoreTypeDef_ClassType.h:41
#define ZF_IN
dummy macro that shows the param used as required input
Definition ZFCoreTypeDef_ClassType.h:180
zfint zfmemcmp(const void *p1, const void *p2, zfindex size)
wrapper to memcmp
Definition ZFCoreTypeDef_ClassType.h:144
#define zfclassNotPOD
shows the class is not a POD type, you should not memset it or declare it in stack or copy value by c...
Definition ZFCoreTypeDef_ClassType.h:48
_ZFT_t_zfint zfint
same as int, see zfindex
Definition ZFCoreTypeDef_CoreType.h:165
_zft_zfidentity zfidentity
identity type, ensured at least 32 bit, ensured unsigned
Definition ZFCoreTypeDef_CoreType.h:225
#define zftTraitsModifierName_CPCR
see zftTraits::ModifierName
Definition ZFCoreUtilTemplate.h:92
#define zftTraitsModifierName_N
see zftTraits::ModifierName
Definition ZFCoreUtilTemplate.h:76
#define zftTraitsModifierName_PR
see zftTraits::ModifierName
Definition ZFCoreUtilTemplate.h:84
zftTraitsModifier
see zftTraits::ModifierName
Definition ZFCoreUtilTemplate.h:64
@ zftTraitsModifier_CP
see zftTraits::ModifierName
Definition ZFCoreUtilTemplate.h:71
@ zftTraitsModifier_CPR
see zftTraits::ModifierName
Definition ZFCoreUtilTemplate.h:72
@ zftTraitsModifier_R
see zftTraits::ModifierName
Definition ZFCoreUtilTemplate.h:66
@ zftTraitsModifier_N
see zftTraits::ModifierName
Definition ZFCoreUtilTemplate.h:65
@ zftTraitsModifier_P
see zftTraits::ModifierName
Definition ZFCoreUtilTemplate.h:68
@ zftTraitsModifier_PR
see zftTraits::ModifierName
Definition ZFCoreUtilTemplate.h:69
@ zftTraitsModifier_CPCR
see zftTraits::ModifierName
Definition ZFCoreUtilTemplate.h:73
@ zftTraitsModifier_PCR
see zftTraits::ModifierName
Definition ZFCoreUtilTemplate.h:70
@ zftTraitsModifier_CR
see zftTraits::ModifierName
Definition ZFCoreUtilTemplate.h:67
#define zftTraitsModifierName_CR
see zftTraits::ModifierName
Definition ZFCoreUtilTemplate.h:80
#define zftTraitsModifierName_CPR
see zftTraits::ModifierName
Definition ZFCoreUtilTemplate.h:90
#define zftTraitsModifierName_P
see zftTraits::ModifierName
Definition ZFCoreUtilTemplate.h:82
zfint zfcmpPOD(T_Element const &v0, T_Element const &v1)
util method to compare two POD type
Definition ZFCoreUtilTemplate.h:548
#define zftTraitsModifierName_R
see zftTraits::ModifierName
Definition ZFCoreUtilTemplate.h:78
#define zftTraitsModifierName_PCR
see zftTraits::ModifierName
Definition ZFCoreUtilTemplate.h:86
#define zftTraitsModifierName_CP
see zftTraits::ModifierName
Definition ZFCoreUtilTemplate.h:88
zfidentity zfhash(const T_Type &v)
std::hash wrapper
Definition ZFCoreUtilTemplate.h:518
identity generator utility
zfidentity zfidentityCalc(T_Type const &v)
calculate identity from POD object
Definition ZFIdentityUtil.h:92
#define ZF_NAMESPACE_GLOBAL_BEGIN
begin namespace ZFFramework
Definition ZFNamespace.h:97
#define ZF_NAMESPACE_GLOBAL_END
end namespace ZFFramework
Definition ZFNamespace.h:98
void Value
std::enable_if wrapper
Definition ZFCoreUtilTemplate.h:418
std::enable_if wrapper
Definition ZFCoreUtilTemplate.h:411
std::hash wrapper
Definition ZFCoreUtilTemplate.h:509
static zfidentity value(const T_Type &v)
std::hash wrapper
Definition ZFCoreUtilTemplate.h:512
std::is_class wrapper
Definition ZFCoreUtilTemplate.h:444
@ Value
std::is_class wrapper
Definition ZFCoreUtilTemplate.h:453
std::is_pod wrapper
Definition ZFCoreUtilTemplate.h:499
@ Value
std::is_pod wrapper
Definition ZFCoreUtilTemplate.h:503
@ Value
std::is_same wrapper
Definition ZFCoreUtilTemplate.h:437
std::is_same wrapper
Definition ZFCoreUtilTemplate.h:424
@ Value
std::is_same wrapper
Definition ZFCoreUtilTemplate.h:428
@ Value
std::is_base_of wrapper
Definition ZFCoreUtilTemplate.h:492
@ Value
std::is_base_of wrapper
Definition ZFCoreUtilTemplate.h:483
std::is_base_of wrapper
Definition ZFCoreUtilTemplate.h:461
@ Value
std::is_base_of wrapper
Definition ZFCoreUtilTemplate.h:474
type traits similar to STL's traits
Definition ZFCoreUtilTemplate.h:100
T_Type TrNoRef
remove reference
Definition ZFCoreUtilTemplate.h:112
static const zfchar * ModifierName(void)
type modifier name
Definition ZFCoreUtilTemplate.h:126
const T_Type * TrConstPtr
const pointer type
Definition ZFCoreUtilTemplate.h:111
T_Type & TrRef
reference type
Definition ZFCoreUtilTemplate.h:108
T_Type TrType
normal type
Definition ZFCoreUtilTemplate.h:107
T_Type * TrPtr
pointer type
Definition ZFCoreUtilTemplate.h:110
@ TrModifier
true if the type is reference type
Definition ZFCoreUtilTemplate.h:105
@ TrIsRef
true if the type is pointer type
Definition ZFCoreUtilTemplate.h:104
T_Type const & TrConstRef
const reference type
Definition ZFCoreUtilTemplate.h:109
util wrapper class to hold a type
Definition ZFCoreUtilTemplate.h:21
T_Type zfv
the wrapped value
Definition ZFCoreUtilTemplate.h:24