1 #ifndef PROTON_INTERNAL_TYPE_TRAITS_HPP 2 #define PROTON_INTERNAL_TYPE_TRAITS_HPP 30 #include "./config.hpp" 31 #include "../types_fwd.hpp" 32 #include "../type_id.hpp" 34 #include <proton/type_compat.h> 44 template <
bool,
class T=
void>
struct enable_if {};
45 template <
class T>
struct enable_if<true, T> {
typedef T type; };
47 struct true_type {
static const bool value =
true; };
48 struct false_type {
static const bool value =
false; };
50 template <
class T>
struct is_integral :
public false_type {};
51 template <
class T>
struct is_signed :
public false_type {};
53 template <>
struct is_integral<char> :
public true_type {};
54 template <>
struct is_signed<char> {
static const bool value = std::numeric_limits<char>::is_signed; };
56 template <>
struct is_integral<unsigned char> :
public true_type {};
57 template <>
struct is_integral<unsigned short> :
public true_type {};
58 template <>
struct is_integral<unsigned int> :
public true_type {};
59 template <>
struct is_integral<unsigned long> :
public true_type {};
61 template <>
struct is_integral<signed char> :
public true_type {};
62 template <>
struct is_integral<signed short> :
public true_type {};
63 template <>
struct is_integral<signed int> :
public true_type {};
64 template <>
struct is_integral<signed long> :
public true_type {};
66 template <>
struct is_signed<unsigned short> :
public false_type {};
67 template <>
struct is_signed<unsigned int> :
public false_type {};
68 template <>
struct is_signed<unsigned long> :
public false_type {};
70 template <>
struct is_signed<signed char> :
public true_type {};
71 template <>
struct is_signed<signed short> :
public true_type {};
72 template <>
struct is_signed<signed int> :
public true_type {};
73 template <>
struct is_signed<signed long> :
public true_type {};
75 #if PN_CPP_HAS_LONG_LONG 76 template <>
struct is_integral<unsigned long long> :
public true_type {};
77 template <>
struct is_integral<signed long long> :
public true_type {};
78 template <>
struct is_signed<unsigned long long> :
public false_type {};
79 template <>
struct is_signed<signed long long> :
public true_type {};
82 template <
class T,
class U>
struct is_same {
static const bool value=
false; };
83 template <
class T>
struct is_same<T,T> {
static const bool value=
true; };
85 template<
class T >
struct remove_const {
typedef T type; };
86 template<
class T >
struct remove_const<const T> {
typedef T type; };
88 template <type_
id ID,
class T>
struct type_id_constant {
90 static const type_id value = ID;
95 template <
class T>
struct type_id_of;
96 template<>
struct type_id_of<bool> :
public type_id_constant<BOOLEAN, bool> {};
97 template<>
struct type_id_of<uint8_t> :
public type_id_constant<UBYTE, uint8_t> {};
98 template<>
struct type_id_of<int8_t> :
public type_id_constant<BYTE, int8_t> {};
99 template<>
struct type_id_of<uint16_t> :
public type_id_constant<USHORT, uint16_t> {};
100 template<>
struct type_id_of<int16_t> :
public type_id_constant<SHORT, int16_t> {};
101 template<>
struct type_id_of<uint32_t> :
public type_id_constant<UINT, uint32_t> {};
102 template<>
struct type_id_of<int32_t> :
public type_id_constant<INT, int32_t> {};
103 template<>
struct type_id_of<uint64_t> :
public type_id_constant<ULONG, uint64_t> {};
104 template<>
struct type_id_of<int64_t> :
public type_id_constant<LONG, int64_t> {};
105 template<>
struct type_id_of<wchar_t> :
public type_id_constant<CHAR, wchar_t> {};
106 template<>
struct type_id_of<float> :
public type_id_constant<FLOAT, float> {};
107 template<>
struct type_id_of<double> :
public type_id_constant<DOUBLE, double> {};
108 template<>
struct type_id_of<timestamp> :
public type_id_constant<TIMESTAMP, timestamp> {};
109 template<>
struct type_id_of<decimal32> :
public type_id_constant<DECIMAL32, decimal32> {};
110 template<>
struct type_id_of<decimal64> :
public type_id_constant<DECIMAL64, decimal64> {};
111 template<>
struct type_id_of<decimal128> :
public type_id_constant<DECIMAL128, decimal128> {};
112 template<>
struct type_id_of<uuid> :
public type_id_constant<UUID, uuid> {};
113 template<>
struct type_id_of<
std::string> :
public type_id_constant<STRING, std::string> {};
114 template<>
struct type_id_of<symbol> :
public type_id_constant<SYMBOL, symbol> {};
115 template<>
struct type_id_of<binary> :
public type_id_constant<BINARY, binary> {};
119 template <
class T,
class Enable=
void>
struct has_type_id :
public false_type {};
120 template <
class T>
struct has_type_id<T, typename type_id_of<T>::type> :
public true_type {};
136 template<
size_t SIZE,
bool IS_SIGNED>
struct integer_type;
137 template<>
struct integer_type<1, true> {
typedef int8_t type; };
138 template<>
struct integer_type<2, true> {
typedef int16_t type; };
139 template<>
struct integer_type<4, true> {
typedef int32_t type; };
140 template<>
struct integer_type<8, true> {
typedef int64_t type; };
141 template<>
struct integer_type<1, false> {
typedef uint8_t type; };
142 template<>
struct integer_type<2, false> {
typedef uint16_t type; };
143 template<>
struct integer_type<4, false> {
typedef uint32_t type; };
144 template<>
struct integer_type<8, false> {
typedef uint64_t type; };
147 template <
class T>
struct is_unknown_integer {
148 static const bool value = !has_type_id<T>::value && is_integral<T>::value;
151 template<class T, class = typename enable_if<is_unknown_integer<T>::value>::type>
152 struct known_integer :
public integer_type<sizeof(T), is_signed<T>::value> {};
160 template <
typename T > any_t(T
const&);
164 template <
class From,
class To>
struct is_convertible :
public sfinae {
165 static yes test(
const To&);
167 static const From& from;
172 #pragma warning( push ) 173 #pragma warning( disable : 4244 ) 175 static bool const value =
sizeof(test(from)) ==
sizeof(yes);
177 #pragma warning( pop ) 184 #endif // PROTON_INTERNAL_TYPE_TRAITS_HPP
type_id
An identifier for AMQP types.
Definition: type_id.hpp:38
The main Proton namespace.
Definition: annotation_key.hpp:30