27 #ifdef ONIXS_CONFLATEDTCP_HAS_TYPE_TRAITS 28 # include <type_traits> 33 #ifdef ONIXS_CONFLATEDTCP_HAS_TYPE_TRAITS 36 template <
bool B,
class T =
void>
37 using EnableIf = std::enable_if<B, T>;
40 template <
typename Base,
typename Derived>
41 using IsBaseOf = std::is_base_of<Base, Derived>;
45 using IsSigned = std::is_signed<T>;
47 #define CHECK_TYPE_INTEGRAL(Type) \ 49 std::is_integral<Type>::value, \ 50 #Type " must be an integral type, consider adding MemberTraits" \ 55 template <
bool B,
class T =
void>
63 struct EnableIf<false, T> {};
66 template<
typename Base,
typename Derived>
69 enum { value = __is_base_of(Base, Derived)};
76 enum { value = (!(
static_cast<T
>(-1) > static_cast<T>(0))) };
79 #define CHECK_TYPE_INTEGRAL(Type) 86 template <
class T,
class U>
89 enum { value = (
static_cast<bool>(IsSigned<T>::value) == static_cast<bool>(IsSigned<U>::value)) };
96 template<
typename U>
struct SFINAE {};
98 template<
typename U>
static int test(...);
108 template<
typename U>
static int test(...);
116 enum { value = HasMantissa<T>::value && HasExponent<T>::value };
125 struct AreBothDecimals
127 enum { value = IsDecimal<Decimal1>::value && IsDecimal<Decimal2>::value };
132 struct HasMemberTraits
136 template<
typename U>
static int test(...);
142 struct HasValueStaticMember
144 template<
typename U,
typename U::Value (*)()>
struct SFINAE {};
146 template<
typename U>
static int test(...);
152 struct HasSerializeMember
154 template<
typename U,
void (U::*)(
void*) const ONIXS_CONFLATEDTCP_NOTHROW>
struct SFINAE {};
156 template<
typename U>
static int test(...);
162 template <
class To,
class From>
165 typename EnableIf<details::IsSameSignedness<To, From>::value, To>::type
169 static_cast<To
>(from);
171 assert(static_cast<From>(to) == from);
177 template <
class To,
class From>
180 typename EnableIf<!details::IsSameSignedness<To, From>::value, To>::type
184 static_cast<To
>(from);
186 assert(static_cast<From>(to) == from);
189 assert((to > static_cast<To>(0)) == (from > static_cast<From>(0)));
#define ONIXS_CONFLATEDTCP_MESSAGING_NAMESPACE_END
#define ONIXS_CONFLATEDTCP_NOTHROW
#define ONIXS_CONFLATEDTCP_PURE
#define ONIXS_CONFLATEDTCP_MESSAGING_NAMESPACE_BEGIN
#define ONIXS_CONFLATEDTCP_NULLPTR