Skip to content

operator== documentation should show how to apply custom comparison function #1915

Description

@nmusolino

What is the issue you have?

The documentation for operator == mentions that double NaN values compare unequal, and says, "To compare floating-point while respecting an epsilon, an alternative comparison function could be used..." The example function is for comparing two doubles.

In issue #514, about comparison between NaN values, @nlohmann wrote:

I think nothing must be changed here, only the documentation must be clear.

The documentation for operator == should illustrate how a custom double comparison function could be applied recursively to all values in a basic_json object. This would allow users to easily write their own function to evaluate two basic_json objects for equivalence.

I think such a function could be written using basic_json::flatten() and comparing items pairwise with the std::equal algorithm.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions