From 21dcd4bd3961978de6d1a491244b88d222c609cc Mon Sep 17 00:00:00 2001 From: Pratik Chowdhury Date: Sun, 9 Dec 2018 16:34:38 +0530 Subject: [PATCH] Fixes https://github.com/nlohmann/json/issues/1387 In https://github.com/nlohmann/json/issues/1387, a user was facing difficulty because he was using map class. Map class sorts it's elements on the basis of < function. Now this meant that the bug existed in inline bool operator< If you are to look at the Numerics Mentioned beside the comment in the previous code base, you would find that they do not match the one mentioned/implied in enum class value_t The correction of these values fixes the issue altogether --- include/nlohmann/detail/value_t.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/nlohmann/detail/value_t.hpp b/include/nlohmann/detail/value_t.hpp index 10d555b99..873fdc3ca 100644 --- a/include/nlohmann/detail/value_t.hpp +++ b/include/nlohmann/detail/value_t.hpp @@ -63,8 +63,8 @@ Returns an ordering that is similar to Python: inline bool operator<(const value_t lhs, const value_t rhs) noexcept { static constexpr std::array order = {{ - 0 /* null */, 3 /* object */, 4 /* array */, 5 /* string */, - 1 /* boolean */, 2 /* integer */, 2 /* unsigned */, 2 /* float */ + 0 /* null */, 1 /* object */, 2 /* array */, 3 /* string */, + 4 /* boolean */, 5 /* integer */, 6 /* unsigned */, 7 /* float */ } };