From 03a75d58fcae9a3aef73fe4a2bea80c937b2f08e Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Wed, 20 Oct 2021 14:19:45 +0200 Subject: [PATCH] :rotating_light: fix warnings --- .../nlohmann/detail/conversions/from_json.hpp | 4 +-- .../nlohmann/detail/conversions/to_json.hpp | 4 +-- include/nlohmann/detail/meta/cpp_future.hpp | 2 -- single_include/nlohmann/json.hpp | 10 +++--- test/src/unit-regression1.cpp | 2 +- test/src/unit-regression2.cpp | 34 ++++++++++++++----- 6 files changed, 34 insertions(+), 22 deletions(-) diff --git a/include/nlohmann/detail/conversions/from_json.hpp b/include/nlohmann/detail/conversions/from_json.hpp index e2fb89f26..578a57c3e 100644 --- a/include/nlohmann/detail/conversions/from_json.hpp +++ b/include/nlohmann/detail/conversions/from_json.hpp @@ -25,13 +25,13 @@ namespace nlohmann::detail { namespace std_fs = std::experimental::filesystem; -} +} // namespace nlohmann::detail #else #include namespace nlohmann::detail { namespace std_fs = std::filesystem; -} +} // namespace nlohmann::detail #endif #endif diff --git a/include/nlohmann/detail/conversions/to_json.hpp b/include/nlohmann/detail/conversions/to_json.hpp index c11213114..f53b566e1 100644 --- a/include/nlohmann/detail/conversions/to_json.hpp +++ b/include/nlohmann/detail/conversions/to_json.hpp @@ -21,13 +21,13 @@ namespace nlohmann::detail { namespace std_fs = std::experimental::filesystem; -} +} // namespace nlohmann::detail #else #include namespace nlohmann::detail { namespace std_fs = std::filesystem; -} +} // namespace nlohmann::detail #endif #endif diff --git a/include/nlohmann/detail/meta/cpp_future.hpp b/include/nlohmann/detail/meta/cpp_future.hpp index e24518faf..30435ef67 100644 --- a/include/nlohmann/detail/meta/cpp_future.hpp +++ b/include/nlohmann/detail/meta/cpp_future.hpp @@ -147,8 +147,6 @@ struct static_const static constexpr T value{}; }; -template -constexpr T static_const::value; } // namespace detail } // namespace nlohmann diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 3d77c72a7..1d66d6dd7 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -3314,8 +3314,6 @@ struct static_const static constexpr T value{}; }; -template -constexpr T static_const::value; } // namespace detail } // namespace nlohmann @@ -3973,13 +3971,13 @@ T conditional_static_cast(U value) namespace nlohmann::detail { namespace std_fs = std::experimental::filesystem; -} +} // namespace nlohmann::detail #else #include namespace nlohmann::detail { namespace std_fs = std::filesystem; -} +} // namespace nlohmann::detail #endif #endif @@ -4661,13 +4659,13 @@ class tuple_element> namespace nlohmann::detail { namespace std_fs = std::experimental::filesystem; -} +} // namespace nlohmann::detail #else #include namespace nlohmann::detail { namespace std_fs = std::filesystem; -} +} // namespace nlohmann::detail #endif #endif diff --git a/test/src/unit-regression1.cpp b/test/src/unit-regression1.cpp index 92c27ff4e..3971addca 100644 --- a/test/src/unit-regression1.cpp +++ b/test/src/unit-regression1.cpp @@ -205,7 +205,7 @@ TEST_CASE("regression tests 1") // check if the actual value was stored CHECK(j2 == 102); - static_assert(std::is_same::value, ""); + static_assert(std::is_same::value, "types must be the same"); j.push_back(json::object( { diff --git a/test/src/unit-regression2.cpp b/test/src/unit-regression2.cpp index 07b21ff5e..158e27748 100644 --- a/test/src/unit-regression2.cpp +++ b/test/src/unit-regression2.cpp @@ -48,18 +48,34 @@ using ordered_json = nlohmann::ordered_json; #ifdef JSON_HAS_CPP_17 #include + +// set JSON_STD_FILESYSTEM_EXPERIMENTAL to 1 if should be taken instead of +#if defined(__cpp_lib_filesystem) + #define JSON_STD_FILESYSTEM_EXPERIMENTAL 0 +#elif defined(__cpp_lib_experimental_filesystem) + #define JSON_STD_FILESYSTEM_EXPERIMENTAL 1 +#elif !defined(__has_include) + #define JSON_STD_FILESYSTEM_EXPERIMENTAL 1 +#elif __has_include() + #define JSON_STD_FILESYSTEM_EXPERIMENTAL 0 +#elif __has_include() + #define JSON_STD_FILESYSTEM_EXPERIMENTAL 1 +#else + #define JSON_STD_FILESYSTEM_EXPERIMENTAL 0 +#endif + #if JSON_STD_FILESYSTEM_EXPERIMENTAL #include namespace nlohmann::detail { namespace std_fs = std::experimental::filesystem; -} +} // namespace nlohmann::detail #else #include namespace nlohmann::detail { namespace std_fs = std::filesystem; -} +} // namespace nlohmann::detail #endif #endif @@ -504,15 +520,15 @@ TEST_CASE("regression tests 2") SECTION("issue #1805 - A pair is json constructible only if T1 and T2 are json constructible") { - static_assert(!std::is_constructible>::value, ""); - static_assert(!std::is_constructible>::value, ""); - static_assert(std::is_constructible>::value, ""); + static_assert(!std::is_constructible>::value, "unexpected result"); + static_assert(!std::is_constructible>::value, "unexpected result"); + static_assert(std::is_constructible>::value, "unexpected result"); } SECTION("issue #1825 - A tuple is json constructible only if all T in Args are json constructible") { - static_assert(!std::is_constructible>::value, ""); - static_assert(!std::is_constructible>::value, ""); - static_assert(std::is_constructible>::value, ""); + static_assert(!std::is_constructible>::value, "unexpected result"); + static_assert(!std::is_constructible>::value, "unexpected result"); + static_assert(std::is_constructible>::value, "unexpected result"); } SECTION("issue #1983 - JSON patch diff for op=add formation is not as per standard (RFC 6902)") @@ -709,7 +725,7 @@ TEST_CASE("regression tests 2") SECTION("issue #2825 - Properly constrain the basic_json conversion operator") { - static_assert(std::is_copy_assignable::value, ""); + static_assert(std::is_copy_assignable::value, "ordered_json must be copy assignable"); } SECTION("issue #2958 - Inserting in unordered json using a pointer retains the leading slash")