Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/yaml-cpp/traits.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 #ifndef TRAITS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
0002 #define TRAITS_H_62B23520_7C8E_11DE_8A39_0800200C9A66
0003 
0004 #if defined(_MSC_VER) ||                                            \
0005     (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \
0006      (__GNUC__ >= 4))  // GCC supports "pragma once" correctly since 3.4
0007 #pragma once
0008 #endif
0009 
0010 #include <type_traits>
0011 #include <utility>
0012 #include <string>
0013 #include <sstream>
0014 
0015 namespace YAML {
0016 template <typename>
0017 struct is_numeric {
0018   enum { value = false };
0019 };
0020 
0021 template <>
0022 struct is_numeric<char> {
0023   enum { value = true };
0024 };
0025 template <>
0026 struct is_numeric<unsigned char> {
0027   enum { value = true };
0028 };
0029 template <>
0030 struct is_numeric<int> {
0031   enum { value = true };
0032 };
0033 template <>
0034 struct is_numeric<unsigned int> {
0035   enum { value = true };
0036 };
0037 template <>
0038 struct is_numeric<long int> {
0039   enum { value = true };
0040 };
0041 template <>
0042 struct is_numeric<unsigned long int> {
0043   enum { value = true };
0044 };
0045 template <>
0046 struct is_numeric<short int> {
0047   enum { value = true };
0048 };
0049 template <>
0050 struct is_numeric<unsigned short int> {
0051   enum { value = true };
0052 };
0053 #if defined(_MSC_VER) && (_MSC_VER < 1310)
0054 template <>
0055 struct is_numeric<__int64> {
0056   enum { value = true };
0057 };
0058 template <>
0059 struct is_numeric<unsigned __int64> {
0060   enum { value = true };
0061 };
0062 #else
0063 template <>
0064 struct is_numeric<long long> {
0065   enum { value = true };
0066 };
0067 template <>
0068 struct is_numeric<unsigned long long> {
0069   enum { value = true };
0070 };
0071 #endif
0072 template <>
0073 struct is_numeric<float> {
0074   enum { value = true };
0075 };
0076 template <>
0077 struct is_numeric<double> {
0078   enum { value = true };
0079 };
0080 template <>
0081 struct is_numeric<long double> {
0082   enum { value = true };
0083 };
0084 
0085 template <bool, class T = void>
0086 struct enable_if_c {
0087   using type = T;
0088 };
0089 
0090 template <class T>
0091 struct enable_if_c<false, T> {};
0092 
0093 template <class Cond, class T = void>
0094 struct enable_if : public enable_if_c<Cond::value, T> {};
0095 
0096 template <bool, class T = void>
0097 struct disable_if_c {
0098   using type = T;
0099 };
0100 
0101 template <class T>
0102 struct disable_if_c<true, T> {};
0103 
0104 template <class Cond, class T = void>
0105 struct disable_if : public disable_if_c<Cond::value, T> {};
0106 }
0107 
0108 template <typename S, typename T>
0109 struct is_streamable {
0110   template <typename StreamT, typename ValueT>
0111   static auto test(int)
0112       -> decltype(std::declval<StreamT&>() << std::declval<ValueT>(), std::true_type());
0113 
0114   template <typename, typename>
0115   static auto test(...) -> std::false_type;
0116 
0117   static const bool value = decltype(test<S, T>(0))::value;
0118 };
0119 
0120 template<typename Key, bool Streamable>
0121 struct streamable_to_string {
0122   static std::string impl(const Key& key) {
0123     std::stringstream ss;
0124     ss << key;
0125     return ss.str();
0126   }
0127 };
0128 
0129 template<typename Key>
0130 struct streamable_to_string<Key, false> {
0131   static std::string impl(const Key&) {
0132     return "";
0133   }
0134 };
0135 #endif  // TRAITS_H_62B23520_7C8E_11DE_8A39_0800200C9A66