1 #ifndef _NDB_TYPE_TRAITS_H_
2 #define _NDB_TYPE_TRAITS_H_
8 // std::is_trivially_destructible not supported in g++-4.7, so we
9 // do some hacky [conservative] variant of it
11 struct is_trivially_destructible {
12 static const bool value = std::is_scalar<T>::value;
15 template <typename K, typename V>
16 struct is_trivially_destructible<std::pair<K, V>> {
17 static const bool value =
18 is_trivially_destructible<K>::value &&
19 is_trivially_destructible<V>::value;
24 struct is_trivially_copyable : public is_trivially_destructible<T> {};
26 // user types should add their own specializations
29 struct typeutil { typedef const T & func_param_type; };
32 struct primitive_typeutil { typedef T func_param_type; };
34 // specialize typeutil for int types to use primitive_typeutil
36 #define SPECIALIZE_PRIM_TYPEUTIL(tpe) \
37 template <> struct typeutil< tpe > : public primitive_typeutil< tpe > {};
39 SPECIALIZE_PRIM_TYPEUTIL(bool)
40 SPECIALIZE_PRIM_TYPEUTIL(int8_t)
41 SPECIALIZE_PRIM_TYPEUTIL(uint8_t)
42 SPECIALIZE_PRIM_TYPEUTIL(int16_t)
43 SPECIALIZE_PRIM_TYPEUTIL(uint16_t)
44 SPECIALIZE_PRIM_TYPEUTIL(int32_t)
45 SPECIALIZE_PRIM_TYPEUTIL(uint32_t)
46 SPECIALIZE_PRIM_TYPEUTIL(int64_t)
47 SPECIALIZE_PRIM_TYPEUTIL(uint64_t)
50 #endif /* _NDB_TYPE_TRAITS_H_ */