diff --git a/include/yaml-cpp/old-api/conversion.h b/include/yaml-cpp/old-api/conversion.h index ba7eed1..cff904c 100644 --- a/include/yaml-cpp/old-api/conversion.h +++ b/include/yaml-cpp/old-api/conversion.h @@ -14,6 +14,17 @@ namespace YAML { + // traits for conversion + + template + struct is_scalar_convertible { enum { value = is_numeric::value }; }; + + template<> struct is_scalar_convertible { enum { value = true }; }; + template<> struct is_scalar_convertible { enum { value = true }; }; + template<> struct is_scalar_convertible<_Null> { enum { value = true }; }; + + // actual conversion + inline bool Convert(const std::string& input, std::string& output) { output = input; return true; diff --git a/include/yaml-cpp/old-api/node.h b/include/yaml-cpp/old-api/node.h index 44d575a..607d9f0 100644 --- a/include/yaml-cpp/old-api/node.h +++ b/include/yaml-cpp/old-api/node.h @@ -66,7 +66,7 @@ namespace YAML const T to() const; template - friend YAML_CPP_API void operator >> (const Node& node, T& value); + friend YAML_CPP_API typename enable_if >::type operator >> (const Node& node, T& value); // retrieval for maps and sequences template diff --git a/include/yaml-cpp/old-api/nodeimpl.h b/include/yaml-cpp/old-api/nodeimpl.h index e06f53e..7534e04 100644 --- a/include/yaml-cpp/old-api/nodeimpl.h +++ b/include/yaml-cpp/old-api/nodeimpl.h @@ -20,7 +20,7 @@ namespace YAML } template - inline void operator >> (const Node& node, T& value) { + inline typename enable_if >::type operator >> (const Node& node, T& value) { if(!ConvertScalar(node, value)) throw InvalidScalar(node.m_mark); }