diff --git a/include/nodeimpl.h b/include/nodeimpl.h index 3133977..e6cffc3 100644 --- a/include/nodeimpl.h +++ b/include/nodeimpl.h @@ -79,22 +79,22 @@ namespace YAML template inline bool operator == (const T& value, const Node& node) { - return value == node.Read(); + return value == node.operator T(); } template inline bool operator == (const Node& node, const T& value) { - return value == node.Read(); + return value == node.operator T(); } template inline bool operator != (const T& value, const Node& node) { - return value != node.Read(); + return value != node.operator T(); } template inline bool operator != (const Node& node, const T& value) { - return value != node.Read(); + return value != node.operator T(); } inline bool operator == (const char *value, const Node& node) { diff --git a/include/nodereadimpl.h b/include/nodereadimpl.h index 1ea7cf3..1f2341c 100644 --- a/include/nodereadimpl.h +++ b/include/nodereadimpl.h @@ -6,7 +6,18 @@ namespace YAML // (the goal is to call ConvertScalar if we can, and fall back to operator >> if not) // thanks to litb from stackoverflow.com // http://stackoverflow.com/questions/1386183/how-to-call-a-templated-function-if-it-exists-and-something-else-otherwise/1386390#1386390 + + // Note: this doesn't work on gcc 3.2, but does on gcc 3.4 and above. I'm not sure about 3.3. +#if (__GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ <= 3)) + // trick doesn't work? Just fall back to ConvertScalar. + // This means that we can't use any user-defined types as keys in a map + template + inline bool Node::Read(T& value) const { + return ConvertScalar(*this, value); + } +#else + // usual case: the trick! template struct read_impl; @@ -52,6 +63,7 @@ namespace YAML return read_impl::read(*this, value); } +#endif // done with trick // the main conversion function template