"examples/community/sd_text2img_k_diffusion.py" did not exist on "98c42134a5615e1c26f2cca70ff9a4c142850f65"
Commit d78d1653 authored by Jesse Beder's avatar Jesse Beder
Browse files

Set the default operator >> to not compile unless there is a scalar...

Set the default operator >> to not compile unless there is a scalar conversion, so it doesn't interfere with user-defined types
parent 62634f53
...@@ -14,6 +14,17 @@ ...@@ -14,6 +14,17 @@
namespace YAML namespace YAML
{ {
// traits for conversion
template<typename T>
struct is_scalar_convertible { enum { value = is_numeric<T>::value }; };
template<> struct is_scalar_convertible<std::string> { enum { value = true }; };
template<> struct is_scalar_convertible<bool> { enum { value = true }; };
template<> struct is_scalar_convertible<_Null> { enum { value = true }; };
// actual conversion
inline bool Convert(const std::string& input, std::string& output) { inline bool Convert(const std::string& input, std::string& output) {
output = input; output = input;
return true; return true;
......
...@@ -66,7 +66,7 @@ namespace YAML ...@@ -66,7 +66,7 @@ namespace YAML
const T to() const; const T to() const;
template <typename T> template <typename T>
friend YAML_CPP_API void operator >> (const Node& node, T& value); friend YAML_CPP_API typename enable_if<is_scalar_convertible<T> >::type operator >> (const Node& node, T& value);
// retrieval for maps and sequences // retrieval for maps and sequences
template <typename T> template <typename T>
......
...@@ -20,7 +20,7 @@ namespace YAML ...@@ -20,7 +20,7 @@ namespace YAML
} }
template <typename T> template <typename T>
inline void operator >> (const Node& node, T& value) { inline typename enable_if<is_scalar_convertible<T> >::type operator >> (const Node& node, T& value) {
if(!ConvertScalar(node, value)) if(!ConvertScalar(node, value))
throw InvalidScalar(node.m_mark); throw InvalidScalar(node.m_mark);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment