Skip to content

YAML::Node has no comparison operator #265

@GoogleCodeExporter

Description

@GoogleCodeExporter
It isn't possible to use YAML::Node in std::set or std::map due to a lack of 
any comparison operator.

I have a scenario where I need deserialisation of a particular node to always 
return the same instance of the deserialised class. YAML::Node implements the 
equality operator, which means I can easily check if two nodes are actually 
identical, but it has no comparison operator, so I can push them into an 
std::map.

I attempted to write my own comparison operator for the std::map, but I can't 
see any publicly accessible members or accessors to do it.

Furthermore, attempts to use the comparison operator actually work, but it 
looks like the node is implicitly converted to a bool via 
YAML_CPP_OPERATOR_BOOL(). This means the comparison operator always returns 
false.

Is there any sensible way of comparison? I'd settle for internal pointer 
comparison, but it may be more sensible to compare by location in YAML tree or 
something similar.

Original issue reported on code.google.com by sho...@gmail.com on 13 Nov 2014 at 1:51

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions