6 #ifndef DMLC_TYPE_TRAITS_H_ 7 #define DMLC_TYPE_TRAITS_H_ 11 #include <type_traits> 24 static const bool value = std::is_pod<T>::value;
27 static const bool value =
false;
40 static const bool value = std::is_integral<T>::value;
43 static const bool value =
false;
55 static const bool value = std::is_floating_point<T>::value;
58 static const bool value =
false;
70 static const bool value = std::is_arithmetic<T>::value;
90 static inline std::string
value() {
122 template<
bool cond,
typename Then,
typename Else>
126 #define DMLC_DECLARE_TRAITS(Trait, Type, Value) \ 128 struct Trait<Type> { \ 129 static const bool value = Value; \ 133 #define DMLC_DECLARE_TYPE_NAME(Type, Name) \ 135 struct type_name_helper<Type> { \ 136 static inline std::string value() { \ 143 #if DMLC_USE_CXX11 == 0 181 template<
typename Then,
typename Else>
182 struct IfThenElseType<true, Then, Else> {
186 template<
typename Then,
typename Else>
187 struct IfThenElseType<false, Then, Else> {
192 #endif // DMLC_TYPE_TRAITS_H_ static std::string value()
Definition: type_traits.h:90
helper class to construct a string that represents type name
Definition: type_traits.h:86
whether a type is pod type
Definition: type_traits.h:21
DMLC_DECLARE_TRAITS(has_saveload, mxnet::NDArray, true)
traits
whether a type have save/load function
Definition: type_traits.h:110
namespace for dmlc
Definition: array_view.h:12
whether a type is floating point type
Definition: type_traits.h:52
whether a type is integer type
Definition: type_traits.h:37
template to select type based on condition For example, IfThenElseType<true, int, float>::Type will g...
Definition: type_traits.h:123
whether a type is arithemetic type
Definition: type_traits.h:67
static const bool value
the value of the traits
Definition: type_traits.h:24
DMLC_DECLARE_TYPE_NAME(optional< int >,"int or None")
description for optional int
std::string type_name()
the string representation of type name
Definition: type_traits.h:101