6#ifndef _ZFI_ZFCoreUtilTemplate_h_
7#define _ZFI_ZFCoreUtilTemplate_h_
18template<
typename T_Type>
28 template<
typename T_Ref>
zftValue(
ZF_IN T_Ref
const &ref) : zfv(ref) {}
31 template<
typename T_Ref>
inline zftValue<T_Type> &operator = (
ZF_IN T_Ref
const &ref) {zfv = ref;
return *
this;}
32 inline operator T_Type
const & (void)
const {
return zfv;}
33 inline operator T_Type & (void) {
return zfv;}
50 _ZFP_zftType<void(__VA_ARGS__)>::Type
53template<
typename T_Ret,
typename T_Type>
74#define zftTraitsModifierName_N "N"
76#define zftTraitsModifierName_R "R"
78#define zftTraitsModifierName_CR "CR"
80#define zftTraitsModifierName_P "P"
82#define zftTraitsModifierName_PR "PR"
84#define zftTraitsModifierName_PCR "PCR"
86#define zftTraitsModifierName_CP "CP"
88#define zftTraitsModifierName_CPR "CPR"
90#define zftTraitsModifierName_CPCR "CPCR"
97template<
typename T_Type>
147template<
typename T_Type>
155 typedef T_Type TrType;
156 typedef T_Type & TrRef;
157 typedef T_Type
const & TrConstRef;
158 typedef T_Type * TrPtr;
159 typedef const T_Type * TrConstPtr;
160 typedef T_Type TrNoRef;
163template<
typename T_Type>
171 typedef T_Type TrType;
172 typedef T_Type & TrRef;
173 typedef T_Type
const & TrConstRef;
174 typedef T_Type * TrPtr;
175 typedef const T_Type * TrConstPtr;
176 typedef T_Type TrNoRef;
179template<
typename T_Type>
187 typedef T_Type TrType;
188 typedef T_Type & TrRef;
189 typedef T_Type
const & TrConstRef;
190 typedef T_Type * TrPtr;
191 typedef const T_Type * TrConstPtr;
192 typedef T_Type * TrNoRef;
195template<
typename T_Type>
203 typedef T_Type TrType;
204 typedef T_Type & TrRef;
205 typedef T_Type
const & TrConstRef;
206 typedef T_Type * TrPtr;
207 typedef const T_Type * TrConstPtr;
208 typedef T_Type * TrNoRef;
211template<
typename T_Type>
219 typedef T_Type TrType;
220 typedef T_Type & TrRef;
221 typedef T_Type
const & TrConstRef;
222 typedef T_Type * TrPtr;
223 typedef const T_Type * TrConstPtr;
224 typedef T_Type * TrNoRef;
227template<
typename T_Type>
235 typedef T_Type TrType;
236 typedef T_Type & TrRef;
237 typedef T_Type
const & TrConstRef;
238 typedef T_Type * TrPtr;
239 typedef const T_Type * TrConstPtr;
240 typedef const T_Type * TrNoRef;
243template<
typename T_Type>
251 typedef T_Type TrType;
252 typedef T_Type & TrRef;
253 typedef T_Type
const & TrConstRef;
254 typedef T_Type * TrPtr;
255 typedef const T_Type * TrConstPtr;
256 typedef const T_Type * TrNoRef;
259template<
typename T_Type>
267 typedef T_Type TrType;
268 typedef T_Type & TrRef;
269 typedef T_Type
const & TrConstRef;
270 typedef T_Type * TrPtr;
271 typedef const T_Type * TrConstPtr;
272 typedef const T_Type * TrNoRef;
286 typedef void TrConstRef;
287 typedef void * TrPtr;
288 typedef const void * TrConstPtr;
289 typedef void TrNoRef;
300 typedef const void TrType;
301 typedef const void TrRef;
302 typedef const void TrConstRef;
303 typedef const void * TrPtr;
304 typedef const void * TrConstPtr;
305 typedef const void TrNoRef;
318 typedef void *
const & TrConstRef;
319 typedef void * TrPtr;
320 typedef const void * TrConstPtr;
321 typedef void * TrNoRef;
334 typedef const void *
const & TrConstRef;
335 typedef void * TrPtr;
336 typedef const void * TrConstPtr;
337 typedef const void * TrNoRef;
350 typedef void *
const & TrConstRef;
351 typedef void * TrPtr;
352 typedef const void * TrConstPtr;
353 typedef void * TrNoRef;
366 typedef void *
const & TrConstRef;
367 typedef void * TrPtr;
368 typedef const void * TrConstPtr;
369 typedef void * TrNoRef;
382 typedef void *
const & TrConstRef;
383 typedef void * TrPtr;
384 typedef const void * TrConstPtr;
385 typedef const void * TrNoRef;
398 typedef void *
const & TrConstRef;
399 typedef void * TrPtr;
400 typedef const void * TrConstPtr;
401 typedef const void * TrNoRef;
408template<
int cond = 0,
typename T_Fix =
void>
421template<
typename T0,
typename T1>
445 static char _test(
int U::*);
447 static int _test(...);
451 Value = ((
sizeof(_test<T>(0)) ==
sizeof(char)) ? 1 : 0)
457template<
typename TChild,
typename TBase,
461 template<
typename T_Dummy>
462 static char _test(TChild
const &, T_Dummy);
463 static int _test(TBase
const &,
int);
466 operator TChild
const & (void);
467 operator TBase
const & (void)
const;
472 Value = ((
sizeof(_test(_Conv(), 0)) ==
sizeof(char)) ? 1 : 0)
476template<
typename TChild,
typename TBase>
496template<
typename T_Type>
506template<
typename T_Type>
515template<
typename T_Type>
520#define ZFHASH_DECLARE(Type, action) \
523 zfclassNotPOD zftHash<Type > { \
525 static zfidentity value(ZF_IN const Type &v) { \
531#define ZFHASH_DECLARE_TEMPLATE(T_Type, Type, action) \
534 zfclassNotPOD zftHash<Type > { \
536 static zfidentity value(ZF_IN const Type &v) { \
545template<
typename T_Element>
547 ZF_IN T_Element
const &v0
548 ,
ZF_IN T_Element
const &v1
550 return zfmemcmp(&v0, &v1,
sizeof(T_Element));
554#define ZFCORE_POD_DECLARE(Type) \
555 _ZFP_ZFCORE_POD_DECLARE(template<>, _ZFP_ZFCORE_POD_DECLARE_EXPAND(Type)) \
556 _ZFP_ZFCORE_POD_DECLARE_COMPARER(_ZFP_ZFCORE_POD_DECLARE_EMPTY(), _ZFP_ZFCORE_POD_DECLARE_EXPAND(Type))
558#define ZFCORE_POD_DECLARE_TEMPLATE(T_Type, Type) \
559 _ZFP_ZFCORE_POD_DECLARE(_ZFP_ZFCORE_POD_DECLARE_EXPAND(template< T_Type >),_ZFP_ZFCORE_POD_DECLARE_EXPAND(Type)) \
560 _ZFP_ZFCORE_POD_DECLARE_COMPARER(_ZFP_ZFCORE_POD_DECLARE_EXPAND(template< T_Type >), _ZFP_ZFCORE_POD_DECLARE_EXPAND(Type))
563#define ZFCORE_POD_DECLARE_NO_COMPARER(Type) \
564 _ZFP_ZFCORE_POD_DECLARE(template<>,_ZFP_ZFCORE_POD_DECLARE_EXPAND(Type))
566#define ZFCORE_POD_DECLARE_TEMPLATE_NO_COMPARER(T_Type, Type) \
567 _ZFP_ZFCORE_POD_DECLARE(_ZFP_ZFCORE_POD_DECLARE_EXPAND(template< T_Type >),_ZFP_ZFCORE_POD_DECLARE_EXPAND(Type))
569#define _ZFP_ZFCORE_POD_DECLARE_EMPTY(...)
570#define _ZFP_ZFCORE_POD_DECLARE_EXPAND(...) __VA_ARGS__
571#define _ZFP_ZFCORE_POD_DECLARE(classFix, Type) \
574 zfclassNotPOD zftIsPOD<Type > { \
581 zfclassNotPOD zftHash<Type > { \
583 static zfidentity value(ZF_IN const Type &v) { \
584 return zfidentityCalc(v); \
588#define _ZFP_ZFCORE_POD_DECLARE_COMPARER(funcFix, Type) \
590 funcFix inline zfbool operator == (ZF_IN const Type &v0, ZF_IN const Type &v1) {return zfcmpPOD(v0, v1) == 0;} \
591 funcFix inline zfbool operator != (ZF_IN const Type &v0, ZF_IN const Type &v1) {return zfcmpPOD(v0, v1) != 0;} \
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;} \
_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:90
#define zftTraitsModifierName_N
see zftTraits::ModifierName
Definition ZFCoreUtilTemplate.h:74
#define zftTraitsModifierName_PR
see zftTraits::ModifierName
Definition ZFCoreUtilTemplate.h:82
zftTraitsModifier
see zftTraits::ModifierName
Definition ZFCoreUtilTemplate.h:62
@ zftTraitsModifier_CP
see zftTraits::ModifierName
Definition ZFCoreUtilTemplate.h:69
@ zftTraitsModifier_CPR
see zftTraits::ModifierName
Definition ZFCoreUtilTemplate.h:70
@ zftTraitsModifier_R
see zftTraits::ModifierName
Definition ZFCoreUtilTemplate.h:64
@ zftTraitsModifier_N
see zftTraits::ModifierName
Definition ZFCoreUtilTemplate.h:63
@ zftTraitsModifier_P
see zftTraits::ModifierName
Definition ZFCoreUtilTemplate.h:66
@ zftTraitsModifier_PR
see zftTraits::ModifierName
Definition ZFCoreUtilTemplate.h:67
@ zftTraitsModifier_CPCR
see zftTraits::ModifierName
Definition ZFCoreUtilTemplate.h:71
@ zftTraitsModifier_PCR
see zftTraits::ModifierName
Definition ZFCoreUtilTemplate.h:68
@ zftTraitsModifier_CR
see zftTraits::ModifierName
Definition ZFCoreUtilTemplate.h:65
#define zftTraitsModifierName_CR
see zftTraits::ModifierName
Definition ZFCoreUtilTemplate.h:78
#define zftTraitsModifierName_CPR
see zftTraits::ModifierName
Definition ZFCoreUtilTemplate.h:88
#define zftTraitsModifierName_P
see zftTraits::ModifierName
Definition ZFCoreUtilTemplate.h:80
zfint zfcmpPOD(T_Element const &v0, T_Element const &v1)
util method to compare two POD type
Definition ZFCoreUtilTemplate.h:546
#define zftTraitsModifierName_R
see zftTraits::ModifierName
Definition ZFCoreUtilTemplate.h:76
#define zftTraitsModifierName_PCR
see zftTraits::ModifierName
Definition ZFCoreUtilTemplate.h:84
#define zftTraitsModifierName_CP
see zftTraits::ModifierName
Definition ZFCoreUtilTemplate.h:86
zfidentity zfhash(const T_Type &v)
std::hash wrapper
Definition ZFCoreUtilTemplate.h:516
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:416
std::enable_if wrapper
Definition ZFCoreUtilTemplate.h:409
std::hash wrapper
Definition ZFCoreUtilTemplate.h:507
static zfidentity value(const T_Type &v)
std::hash wrapper
Definition ZFCoreUtilTemplate.h:510
std::is_class wrapper
Definition ZFCoreUtilTemplate.h:442
@ Value
std::is_class wrapper
Definition ZFCoreUtilTemplate.h:451
std::is_pod wrapper
Definition ZFCoreUtilTemplate.h:497
@ Value
std::is_pod wrapper
Definition ZFCoreUtilTemplate.h:501
@ Value
std::is_same wrapper
Definition ZFCoreUtilTemplate.h:435
std::is_same wrapper
Definition ZFCoreUtilTemplate.h:422
@ Value
std::is_same wrapper
Definition ZFCoreUtilTemplate.h:426
@ Value
std::is_base_of wrapper
Definition ZFCoreUtilTemplate.h:490
@ Value
std::is_base_of wrapper
Definition ZFCoreUtilTemplate.h:481
std::is_base_of wrapper
Definition ZFCoreUtilTemplate.h:459
@ Value
std::is_base_of wrapper
Definition ZFCoreUtilTemplate.h:472
type traits similar to STL's traits
Definition ZFCoreUtilTemplate.h:98
T_Type TrNoRef
remove reference
Definition ZFCoreUtilTemplate.h:110
static const zfchar * ModifierName(void)
type modifier name
Definition ZFCoreUtilTemplate.h:124
const T_Type * TrConstPtr
const pointer type
Definition ZFCoreUtilTemplate.h:109
T_Type & TrRef
reference type
Definition ZFCoreUtilTemplate.h:106
T_Type TrType
normal type
Definition ZFCoreUtilTemplate.h:105
T_Type * TrPtr
pointer type
Definition ZFCoreUtilTemplate.h:108
@ TrModifier
true if the type is reference type
Definition ZFCoreUtilTemplate.h:103
@ TrIsRef
true if the type is pointer type
Definition ZFCoreUtilTemplate.h:102
T_Type const & TrConstRef
const reference type
Definition ZFCoreUtilTemplate.h:107
util wrapper class to hold a type
Definition ZFCoreUtilTemplate.h:19
T_Type zfv
the wrapped value
Definition ZFCoreUtilTemplate.h:22