CppWAMP
C++11 client library for the WAMP protocol
|
Go to the documentation of this file.
7 #ifndef CPPWAMP_TRAITS_HPP
8 #define CPPWAMP_TRAITS_HPP
11 #include <type_traits>
22 #ifdef CPPWAMP_FOR_DOXYGEN
23 #define CPPWAMP_ENABLE_IF(cond)
24 #define CPPWAMP_ENABLED_TYPE(type, cond) type
26 #define CPPWAMP_ENABLE_IF(cond) EnableIf<(cond)>
27 #define CPPWAMP_ENABLED_TYPE(type, cond) EnableIf<(cond), type>
36 template<
bool B,
typename T =
int>
37 using EnableIf =
typename std::enable_if<B,T>::type;
42 template<
bool B,
typename T =
int>
43 using DisableIf =
typename std::enable_if<!B,T>::type;
51 typename std::remove_cv<typename std::remove_reference<T>::type>::type;
56 template<
typename T,
typename U>
57 CPPWAMP_API constexpr
bool isSameType() {
return std::is_same<T, U>::value;}
66 return isSameType<T, bool>() ||
67 isSameType<T, std::vector<bool>::reference>() ||
68 isSameType<T, std::vector<bool>::const_reference>();
79 return std::is_arithmetic<T>::value && !isSameType<T, bool>();
88 return std::is_integral<T>::value && std::is_signed<T>::value &&
89 !isSameType<T, bool>();
98 return std::is_integral<T>::value && !std::is_signed<T>::value &&
99 !isSameType<T, bool>();
105 template<
int N,
typename... Ts>
using NthTypeOf =
106 typename std::tuple_element<N, std::tuple<Ts...>>::type;
126 #endif // CPPWAMP_TRAITS_HPP
typename std::enable_if<!B, T >::type DisableIf
Metafunction used to disable overloads based on a boolean condition.
Definition: traits.hpp:43
BoolConstant< false > FalseType
Equivalent to std::false_type provided in C++17.
Definition: traits.hpp:122
constexpr bool isSignedInteger()
Determines if the given type is a signed integer.
Definition: traits.hpp:86
BoolConstant< true > TrueType
Equivalent to std::true_type provided in C++17.
Definition: traits.hpp:117
Defines macros related to exporting/importing APIs.
constexpr bool isSameType()
Determines if a type is the same as another.
Definition: traits.hpp:57
Definition: anyhandler.hpp:36
constexpr bool isUnsignedInteger()
Determines if the given type is an unsigned integer.
Definition: traits.hpp:96
typename std::remove_cv< typename std::remove_reference< T >::type >::type ValueTypeOf
Metafunction used to obtain the plain value type of a parameter passed by universal reference.
Definition: traits.hpp:51
typename std::enable_if< B, T >::type EnableIf
Metafunction used to enable overloads based on a boolean condition.
Definition: traits.hpp:37
constexpr bool isBool()
Determines if the given type is considered a boolean.
Definition: traits.hpp:63
std::integral_constant< bool, B > BoolConstant
Equivalent to std::bool_constant provided in C++17.
Definition: traits.hpp:112
constexpr bool isNumber()
Determines if the given type is considered a number.
Definition: traits.hpp:77
typename std::tuple_element< N, std::tuple< Ts... > >::type NthTypeOf
Metafunction that obtains the Nth type of a parameter pack.
Definition: traits.hpp:106