1 #ifndef TRAITS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 #define TRAITS_H_62B23520_7C8E_11DE_8A39_0800200C9A66 4 #if defined(_MSC_VER) || \ 5 (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 10 #include <type_traits> 18 enum { value =
false };
22 struct is_numeric<char> {
23 enum { value =
true };
26 struct is_numeric<unsigned char> {
27 enum { value =
true };
30 struct is_numeric<int> {
31 enum { value =
true };
34 struct is_numeric<unsigned int> {
35 enum { value =
true };
38 struct is_numeric<long int> {
39 enum { value =
true };
42 struct is_numeric<unsigned long int> {
43 enum { value =
true };
46 struct is_numeric<short int> {
47 enum { value =
true };
50 struct is_numeric<unsigned short int> {
51 enum { value =
true };
53 #if defined(_MSC_VER) && (_MSC_VER < 1310) 55 struct is_numeric<__int64> {
56 enum { value =
true };
59 struct is_numeric<unsigned __int64> {
60 enum { value =
true };
64 struct is_numeric<long long> {
65 enum { value =
true };
68 struct is_numeric<unsigned long long> {
69 enum { value =
true };
73 struct is_numeric<float> {
74 enum { value =
true };
77 struct is_numeric<double> {
78 enum { value =
true };
81 struct is_numeric<long double> {
82 enum { value =
true };
85 template <
bool,
class T =
void>
91 struct enable_if_c<false, T> {};
93 template <
class Cond,
class T =
void>
94 struct enable_if :
public enable_if_c<Cond::value, T> {};
96 template <
bool,
class T =
void>
102 struct disable_if_c<true, T> {};
104 template <
class Cond,
class T =
void>
105 struct disable_if :
public disable_if_c<Cond::value, T> {};
108 template <
typename S,
typename T>
109 struct is_streamable {
110 template <
typename StreamT,
typename ValueT>
111 static auto test(
int)
112 -> decltype(std::declval<StreamT&>() << std::declval<ValueT>(), std::true_type());
114 template <
typename,
typename>
115 static auto test(...) -> std::false_type;
117 static const bool value = decltype(test<S, T>(0))::value;
120 template<
typename Key,
bool Streamable>
121 struct streamable_to_string {
122 static std::string impl(
const Key& key) {
123 std::stringstream ss;
129 template<
typename Key>
130 struct streamable_to_string<Key, false> {
131 static std::string impl(
const Key&) {
135 #endif // TRAITS_H_62B23520_7C8E_11DE_8A39_0800200C9A66