27 #ifdef ONIXS_EURONEXT_OPTIQMDG_HAS_TYPE_TRAITS 28 # include <type_traits> 33 #ifdef ONIXS_EURONEXT_OPTIQMDG_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) 87 template <
class T,
class U>
88 struct IsSameSignedness
90 enum { value = (
static_cast<bool>(IsSigned<T>::value) == static_cast<bool>(IsSigned<U>::value)) };
95 struct HasMemberTraits
97 template<
typename U>
struct SFINAE {};
99 template<
typename U>
static int test(...);
105 struct HasValueStaticMember
107 template<
typename U,
typename U::Value (*)()>
struct SFINAE {};
109 template<
typename U>
static int test(...);
115 struct HasSerializeMember
117 template<
typename U,
void (U::*)(
void*) const ONIXS_EURONEXT_OPTIQMDG_NOTHROW>
struct SFINAE {};
119 template<
typename U>
static int test(...);
129 template<
typename U>
static int test(...);
135 template <
typename Set,
typename NullValue>
136 typename EnableIf<details::HasBitsMember<Set>::value,
bool>::type
139 ONIXS_EURONEXT_OPTIQMDG_STATIC_ASSERT((
sizeof(
typename Set::Bits) ==
sizeof(
typename NullValue::Value)));
140 ONIXS_EURONEXT_OPTIQMDG_STATIC_ASSERT((details::IsSameSignedness<typename Set::Bits, typename NullValue::Value>::value));
142 return set.bits() != null;
146 template <
class To,
class From>
149 typename EnableIf<details::IsSameSignedness<To, From>::value, To>::type
153 static_cast<To
>(from);
155 assert(static_cast<From>(to) == from);
161 template <
class To,
class From>
164 typename EnableIf<!details::IsSameSignedness<To, From>::value, To>::type
168 static_cast<To
>(from);
170 assert(static_cast<From>(to) == from);
173 assert((to > static_cast<To>(0)) == (from > static_cast<From>(0)));
#define ONIXS_EURONEXT_OPTIQMDG_MESSAGING_NAMESPACE_END
#define ONIXS_EURONEXT_OPTIQMDG_NOTHROW
#define ONIXS_EURONEXT_OPTIQMDG_MESSAGING_NAMESPACE_BEGIN
#define ONIXS_EURONEXT_OPTIQMDG_NULLPTR
#define ONIXS_EURONEXT_OPTIQMDG_PURE