1 #ifndef SAFE_ANY_VARNUMBER_H 2 #define SAFE_ANY_VARNUMBER_H 10 #include <type_traits> 23 typename std::enable_if<std::is_integral<T>::value || std::is_enum<T>::value>
::type*;
27 typename std::enable_if<!std::is_integral<T>::value && !std::is_enum<T>::value>::type*;
30 using EnableString =
typename std::enable_if<std::is_same<T, std::string>::value>::type*;
36 using EnableEnum =
typename std::enable_if<std::is_enum<T>::value>::type*;
40 typename std::enable_if<!std::is_arithmetic<T>::value && !std::is_enum<T>::value &&
41 !std::is_same<T, std::string>::value>::type*;
58 Any(
const float& value) :
_any(double(value))
93 const std::type_info&
type() const noexcept
103 template <
typename DST>
112 else if (
type ==
typeid(int64_t))
116 else if (
type ==
typeid(uint64_t))
120 else if (
type ==
typeid(
double))
125 throw errorMsg<DST>();
128 template <
typename DST>
131 using details::convertNumber;
136 if (
type ==
typeid(int64_t))
140 else if (
type ==
typeid(uint64_t))
144 else if (
type ==
typeid(
double))
150 throw errorMsg<DST>();
155 template <
typename DST>
158 using details::convertNumber;
162 if (
type ==
typeid(int64_t))
165 return static_cast<DST
>(out);
167 else if (
type ==
typeid(uint64_t))
170 return static_cast<DST
>(out);
173 throw errorMsg<DST>();
176 template <
typename DST>
179 throw errorMsg<DST>();
182 template <
typename T>
186 sprintf(buffer,
"[Any::convert]: no known safe conversion between %s and %s",
189 return std::runtime_error(buffer);
195 #endif // VARNUMBER_H typename std::enable_if< std::is_integral< T >::value||std::is_enum< T >::value >::type * EnableIntegral
std::runtime_error errorMsg() const
static raw_event_t * buffer
Any(const T &value, EnableIntegral< T >=0)
ValueType any_cast(const any &operand)
Performs *any_cast<add_const_t<remove_reference_t<ValueType>>>(&operand), or throws bad_any_cast on f...
Any(const std::string &str)
typename std::enable_if< std::is_arithmetic< T >::value >::type * EnableArithmetic
const std::type_info & type() const noexcept
Any(const T &value, EnableNonIntegral< T >=0)
DST convert(EnableEnum< DST >=0) const
std::string demangle(char const *name)
typename std::enable_if<!std::is_arithmetic< T >::value &&!std::is_enum< T >::value &&!std::is_same< T, std::string >::value >::type * EnableUnknownType
Any(const uint64_t &value)
DST convert(EnableString< DST >=0) const
const std::type_info & type() const noexcept
If *this has a contained object of type T, typeid(T); otherwise typeid(void).
DST convert(EnableUnknownType< DST >=0) const
typename std::enable_if<!std::is_integral< T >::value &&!std::is_enum< T >::value >::type * EnableNonIntegral
typename std::enable_if< std::is_enum< T >::value >::type * EnableEnum
DST convert(EnableArithmetic< DST >=0) const
std::basic_string< CharT, Traits > to_string(basic_string_view< CharT, Traits > v)
typename std::enable_if< std::is_same< T, std::string >::value >::type * EnableString