diff --git a/src/json.hpp b/src/json.hpp index 33456a515..5bd5bde7a 100644 --- a/src/json.hpp +++ b/src/json.hpp @@ -13048,6 +13048,22 @@ struct hash return h(j.dump()); } }; + +/// specialization for std::less +template <> +struct less<::nlohmann::detail::value_t> +{ + /*! + @brief compare two value_t enum values + @since version 3.0.0 + */ + bool operator()(nlohmann::detail::value_t lhs, + nlohmann::detail::value_t rhs) const noexcept + { + return nlohmann::detail::operator<(lhs, rhs); + } +}; + } // namespace std /*! diff --git a/src/json.hpp.re2c b/src/json.hpp.re2c index 180f5d3b4..baba31076 100644 --- a/src/json.hpp.re2c +++ b/src/json.hpp.re2c @@ -12082,6 +12082,22 @@ struct hash return h(j.dump()); } }; + +/// specialization for std::less +template <> +struct less<::nlohmann::detail::value_t> +{ + /*! + @brief compare two value_t enum values + @since version 3.0.0 + */ + bool operator()(nlohmann::detail::value_t lhs, + nlohmann::detail::value_t rhs) const noexcept + { + return nlohmann::detail::operator<(lhs, rhs); + } +}; + } // namespace std /*! diff --git a/test/src/unit-regression.cpp b/test/src/unit-regression.cpp index bfd2c9547..957d5a25a 100644 --- a/test/src/unit-regression.cpp +++ b/test/src/unit-regression.cpp @@ -796,6 +796,13 @@ TEST_CASE("regression tests") CHECK(s1 == s2); } + SECTION("issue #486 - json::value_t can't be a map's key type in VC++ 2015") + { + // the code below must compile with MSVC + std::map jsonTypes ; + jsonTypes[json::value_t::array] = "array"; + } + SECTION("issue #494 - conversion from vector to json fails to build") { std::vector boolVector = {false, true, false, false};