From 879217d00866b5e9c0ae29256c5cadbed0ea7b8d Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Wed, 20 Oct 2021 12:19:53 +0200 Subject: [PATCH 01/38] :alembic: add C++17 copies of the test binaries --- test/CMakeLists.txt | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 447192cb0f..9342faace9 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -68,6 +68,34 @@ foreach(file ${files}) target_include_directories(${testcase} PRIVATE ${CMAKE_BINARY_DIR}/include thirdparty/doctest thirdparty/fifo_map) target_link_libraries(${testcase} PRIVATE ${NLOHMANN_JSON_TARGET_NAME}) + # add a copy with C++17 compilation + file(READ ${file} FILE_CONTENT) + string(FIND "${FILE_CONTENT}" "JSON_HAS_CPP_17" CPP_17_FOUND) + if(NOT ${CPP_17_FOUND} EQUAL -1) + add_executable(${testcase}_cpp17 $ ${file}) + target_compile_definitions(${testcase}_cpp17 PRIVATE DOCTEST_CONFIG_SUPER_FAST_ASSERTS) + target_compile_options(${testcase}_cpp17 PRIVATE + $<$:/EHsc;$<$:/Od>> + $<$>:-Wno-deprecated;-Wno-float-equal> + $<$:-Wno-deprecated-declarations> + ) + target_include_directories(${testcase}_cpp17 PRIVATE ${CMAKE_BINARY_DIR}/include thirdparty/doctest thirdparty/fifo_map) + target_link_libraries(${testcase}_cpp17 PRIVATE ${NLOHMANN_JSON_TARGET_NAME}) + set_target_properties(${testcase}_cpp17 PROPERTIES CXX_STANDARD 17) + + if (JSON_FastTests) + add_test(NAME "${testcase}_cpp17" + COMMAND ${testcase}_cpp17 ${DOCTEST_TEST_FILTER} + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + ) + else() + add_test(NAME "${testcase}_cpp17" + COMMAND ${testcase}_cpp17 ${DOCTEST_TEST_FILTER} --no-skip + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + ) + endif() + endif() + if (JSON_FastTests) add_test(NAME "${testcase}" COMMAND ${testcase} ${DOCTEST_TEST_FILTER} From cf2a896bcda378f90dd0f70b7b89fa3305513adb Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Wed, 20 Oct 2021 13:03:08 +0200 Subject: [PATCH 02/38] :alembic: add C++17 copies of the test binaries --- test/CMakeLists.txt | 55 ++++++++++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 23 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 9342faace9..76af0f1f87 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -52,6 +52,13 @@ endif() # one executable for each unit test file ############################################################################# +# check if compiler supports C++17 +foreach(feature ${CMAKE_CXX_COMPILE_FEATURES}) + if (${feature} STREQUAL cxx_std_17) + set(compiler_supports_cpp_17 TRUE) + endif() +endforeach() + file(GLOB files src/unit-*.cpp) foreach(file ${files}) @@ -69,30 +76,32 @@ foreach(file ${files}) target_link_libraries(${testcase} PRIVATE ${NLOHMANN_JSON_TARGET_NAME}) # add a copy with C++17 compilation - file(READ ${file} FILE_CONTENT) - string(FIND "${FILE_CONTENT}" "JSON_HAS_CPP_17" CPP_17_FOUND) - if(NOT ${CPP_17_FOUND} EQUAL -1) - add_executable(${testcase}_cpp17 $ ${file}) - target_compile_definitions(${testcase}_cpp17 PRIVATE DOCTEST_CONFIG_SUPER_FAST_ASSERTS) - target_compile_options(${testcase}_cpp17 PRIVATE - $<$:/EHsc;$<$:/Od>> - $<$>:-Wno-deprecated;-Wno-float-equal> - $<$:-Wno-deprecated-declarations> - ) - target_include_directories(${testcase}_cpp17 PRIVATE ${CMAKE_BINARY_DIR}/include thirdparty/doctest thirdparty/fifo_map) - target_link_libraries(${testcase}_cpp17 PRIVATE ${NLOHMANN_JSON_TARGET_NAME}) - set_target_properties(${testcase}_cpp17 PROPERTIES CXX_STANDARD 17) - - if (JSON_FastTests) - add_test(NAME "${testcase}_cpp17" - COMMAND ${testcase}_cpp17 ${DOCTEST_TEST_FILTER} - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - ) - else() - add_test(NAME "${testcase}_cpp17" - COMMAND ${testcase}_cpp17 ${DOCTEST_TEST_FILTER} --no-skip - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + if (compiler_supports_cpp_17) + file(READ ${file} FILE_CONTENT) + string(FIND "${FILE_CONTENT}" "JSON_HAS_CPP_17" CPP_17_FOUND) + if(NOT ${CPP_17_FOUND} EQUAL -1) + add_executable(${testcase}_cpp17 $ ${file}) + target_compile_definitions(${testcase}_cpp17 PRIVATE DOCTEST_CONFIG_SUPER_FAST_ASSERTS) + target_compile_options(${testcase}_cpp17 PRIVATE + $<$:/EHsc;$<$:/Od>> + $<$>:-Wno-deprecated;-Wno-float-equal> + $<$:-Wno-deprecated-declarations> ) + target_include_directories(${testcase}_cpp17 PRIVATE ${CMAKE_BINARY_DIR}/include thirdparty/doctest thirdparty/fifo_map) + target_link_libraries(${testcase}_cpp17 PRIVATE ${NLOHMANN_JSON_TARGET_NAME}) + target_compile_features(${testcase}_cpp17 PRIVATE cxx_std_17) + + if (JSON_FastTests) + add_test(NAME "${testcase}_cpp17" + COMMAND ${testcase}_cpp17 ${DOCTEST_TEST_FILTER} + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + ) + else() + add_test(NAME "${testcase}_cpp17" + COMMAND ${testcase}_cpp17 ${DOCTEST_TEST_FILTER} --no-skip + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + ) + endif() endif() endif() From 7fb709c366b7334ce786487689f5c1e31143fc31 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Wed, 20 Oct 2021 13:11:12 +0200 Subject: [PATCH 03/38] :alembic: add C++17 copies of the test binaries --- test/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 76af0f1f87..5f681e5d00 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -102,6 +102,7 @@ foreach(file ${files}) WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} ) endif() + set_tests_properties("${testcase}_cpp17" PROPERTIES LABELS "all" FIXTURES_REQUIRED TEST_DATA) endif() endif() From d90b6bc721fd7d992023baa5fcc1b300c814db7c Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Wed, 20 Oct 2021 13:52:28 +0200 Subject: [PATCH 04/38] :alembic: use proper header for filesystem --- .clang-tidy | 1 + .../nlohmann/detail/conversions/from_json.hpp | 16 +++++- .../nlohmann/detail/conversions/to_json.hpp | 16 +++++- include/nlohmann/detail/macro_scope.hpp | 17 +++++++ include/nlohmann/detail/macro_unscope.hpp | 1 + single_include/nlohmann/json.hpp | 50 +++++++++++++++++-- test/src/unit-regression2.cpp | 20 ++++++-- 7 files changed, 109 insertions(+), 12 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 33cf84821f..419ef470fa 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -30,6 +30,7 @@ Checks: '*, -llvmlibc-*, -misc-no-recursion, -misc-non-private-member-variables-in-classes, + -modernize-use-nodiscard, -modernize-use-trailing-return-type, -readability-function-size, -readability-function-cognitive-complexity, diff --git a/include/nlohmann/detail/conversions/from_json.hpp b/include/nlohmann/detail/conversions/from_json.hpp index 71e32aaf71..e2fb89f26c 100644 --- a/include/nlohmann/detail/conversions/from_json.hpp +++ b/include/nlohmann/detail/conversions/from_json.hpp @@ -20,7 +20,19 @@ #include #ifdef JSON_HAS_CPP_17 - #include +#if JSON_STD_FILESYSTEM_EXPERIMENTAL +#include +namespace nlohmann::detail +{ +namespace std_fs = std::experimental::filesystem; +} +#else +#include +namespace nlohmann::detail +{ +namespace std_fs = std::filesystem; +} +#endif #endif namespace nlohmann @@ -450,7 +462,7 @@ void from_json(const BasicJsonType& j, std::unordered_map -void from_json(const BasicJsonType& j, std::filesystem::path& p) +void from_json(const BasicJsonType& j, std_fs::path& p) { if (JSON_HEDLEY_UNLIKELY(!j.is_string())) { diff --git a/include/nlohmann/detail/conversions/to_json.hpp b/include/nlohmann/detail/conversions/to_json.hpp index 79fdb3233f..c11213114b 100644 --- a/include/nlohmann/detail/conversions/to_json.hpp +++ b/include/nlohmann/detail/conversions/to_json.hpp @@ -16,7 +16,19 @@ #include #ifdef JSON_HAS_CPP_17 - #include +#if JSON_STD_FILESYSTEM_EXPERIMENTAL +#include +namespace nlohmann::detail +{ +namespace std_fs = std::experimental::filesystem; +} +#else +#include +namespace nlohmann::detail +{ +namespace std_fs = std::filesystem; +} +#endif #endif namespace nlohmann @@ -393,7 +405,7 @@ void to_json(BasicJsonType& j, const T& t) #ifdef JSON_HAS_CPP_17 template -void to_json(BasicJsonType& j, const std::filesystem::path& p) +void to_json(BasicJsonType& j, const std_fs::path& p) { j = p.string(); } diff --git a/include/nlohmann/detail/macro_scope.hpp b/include/nlohmann/detail/macro_scope.hpp index c2a65bdda6..f080db195f 100644 --- a/include/nlohmann/detail/macro_scope.hpp +++ b/include/nlohmann/detail/macro_scope.hpp @@ -37,6 +37,23 @@ #define JSON_HAS_CPP_11 #endif +#ifdef JSON_HAS_CPP_17 + // 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 +#endif + // disable documentation warnings on clang #if defined(__clang__) #pragma clang diagnostic push diff --git a/include/nlohmann/detail/macro_unscope.hpp b/include/nlohmann/detail/macro_unscope.hpp index 67bf1466bc..e0cc5dc40a 100644 --- a/include/nlohmann/detail/macro_unscope.hpp +++ b/include/nlohmann/detail/macro_unscope.hpp @@ -16,6 +16,7 @@ #undef JSON_HAS_CPP_14 #undef JSON_HAS_CPP_17 #undef JSON_HAS_CPP_20 +#undef JSON_STD_FILESYSTEM_EXPERIMENTAL #undef NLOHMANN_BASIC_JSON_TPL_DECLARATION #undef NLOHMANN_BASIC_JSON_TPL #undef JSON_EXPLICIT diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 87475ab31e..3d77c72a7c 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -2325,6 +2325,23 @@ using is_detected_convertible = #define JSON_HAS_CPP_11 #endif +#ifdef JSON_HAS_CPP_17 + // 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 +#endif + // disable documentation warnings on clang #if defined(__clang__) #pragma clang diagnostic push @@ -3951,7 +3968,19 @@ T conditional_static_cast(U value) #ifdef JSON_HAS_CPP_17 - #include +#if JSON_STD_FILESYSTEM_EXPERIMENTAL +#include +namespace nlohmann::detail +{ +namespace std_fs = std::experimental::filesystem; +} +#else +#include +namespace nlohmann::detail +{ +namespace std_fs = std::filesystem; +} +#endif #endif namespace nlohmann @@ -4381,7 +4410,7 @@ void from_json(const BasicJsonType& j, std::unordered_map -void from_json(const BasicJsonType& j, std::filesystem::path& p) +void from_json(const BasicJsonType& j, std_fs::path& p) { if (JSON_HEDLEY_UNLIKELY(!j.is_string())) { @@ -4627,7 +4656,19 @@ class tuple_element> #ifdef JSON_HAS_CPP_17 - #include +#if JSON_STD_FILESYSTEM_EXPERIMENTAL +#include +namespace nlohmann::detail +{ +namespace std_fs = std::experimental::filesystem; +} +#else +#include +namespace nlohmann::detail +{ +namespace std_fs = std::filesystem; +} +#endif #endif namespace nlohmann @@ -5004,7 +5045,7 @@ void to_json(BasicJsonType& j, const T& t) #ifdef JSON_HAS_CPP_17 template -void to_json(BasicJsonType& j, const std::filesystem::path& p) +void to_json(BasicJsonType& j, const std_fs::path& p) { j = p.string(); } @@ -26591,6 +26632,7 @@ inline nlohmann::json::json_pointer operator "" _json_pointer(const char* s, std #undef JSON_HAS_CPP_14 #undef JSON_HAS_CPP_17 #undef JSON_HAS_CPP_20 +#undef JSON_STD_FILESYSTEM_EXPERIMENTAL #undef NLOHMANN_BASIC_JSON_TPL_DECLARATION #undef NLOHMANN_BASIC_JSON_TPL #undef JSON_EXPLICIT diff --git a/test/src/unit-regression2.cpp b/test/src/unit-regression2.cpp index f0c4ef4519..07b21ff5e1 100644 --- a/test/src/unit-regression2.cpp +++ b/test/src/unit-regression2.cpp @@ -47,8 +47,20 @@ using ordered_json = nlohmann::ordered_json; #endif #ifdef JSON_HAS_CPP_17 - #include - #include +#include +#if JSON_STD_FILESYSTEM_EXPERIMENTAL +#include +namespace nlohmann::detail +{ +namespace std_fs = std::experimental::filesystem; +} +#else +#include +namespace nlohmann::detail +{ +namespace std_fs = std::filesystem; +} +#endif #endif #ifdef JSON_HAS_CPP_20 @@ -731,10 +743,10 @@ TEST_CASE("regression tests 2") #ifdef JSON_HAS_CPP_17 SECTION("issue #3070 - Version 3.10.3 breaks backward-compatibility with 3.10.2 ") { - std::filesystem::path text_path("/tmp/text.txt"); + nlohmann::detail::std_fs::path text_path("/tmp/text.txt"); json j(text_path); - const auto j_path = j.get(); + const auto j_path = j.get(); CHECK(j_path == text_path); } #endif From 03a75d58fcae9a3aef73fe4a2bea80c937b2f08e Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Wed, 20 Oct 2021 14:19:45 +0200 Subject: [PATCH 05/38] :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 e2fb89f26c..578a57c3eb 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 c11213114b..f53b566e1d 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 e24518fafe..30435ef671 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 3d77c72a7c..1d66d6dd76 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 92c27ff4e2..3971addca5 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 07b21ff5e1..158e277485 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") From c33bac8352ffb142bbff7efb1109ca63532b98da Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Wed, 20 Oct 2021 14:23:56 +0200 Subject: [PATCH 06/38] :rewind: revert removal of code --- include/nlohmann/detail/meta/cpp_future.hpp | 2 ++ single_include/nlohmann/json.hpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/include/nlohmann/detail/meta/cpp_future.hpp b/include/nlohmann/detail/meta/cpp_future.hpp index 30435ef671..147f2fa357 100644 --- a/include/nlohmann/detail/meta/cpp_future.hpp +++ b/include/nlohmann/detail/meta/cpp_future.hpp @@ -147,6 +147,8 @@ struct static_const static constexpr T value{}; }; +template +constexpr T static_const::value; // NOLINT(readability-redundant-declaration) } // namespace detail } // namespace nlohmann diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 1d66d6dd76..32dd5e1c6c 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -3314,6 +3314,8 @@ struct static_const static constexpr T value{}; }; +template +constexpr T static_const::value; // NOLINT(readability-redundant-declaration) } // namespace detail } // namespace nlohmann From 930e2cf4185fe48970207a11fc1e9198743faeea Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Wed, 20 Oct 2021 14:52:15 +0200 Subject: [PATCH 07/38] :alembic: use proper header for filesystem --- cmake/download_test_data.cmake | 2 +- include/nlohmann/detail/conversions/from_json.hpp | 4 ++-- include/nlohmann/detail/conversions/to_json.hpp | 4 ++-- include/nlohmann/detail/macro_scope.hpp | 5 +++++ single_include/nlohmann/json.hpp | 13 +++++++++---- test/src/unit-regression2.cpp | 11 +++++++---- 6 files changed, 26 insertions(+), 13 deletions(-) diff --git a/cmake/download_test_data.cmake b/cmake/download_test_data.cmake index f516a7c3b2..d2763147c7 100644 --- a/cmake/download_test_data.cmake +++ b/cmake/download_test_data.cmake @@ -53,4 +53,4 @@ else() execute_process(COMMAND ${CMAKE_CXX_COMPILER} --version OUTPUT_VARIABLE CXX_VERSION_RESULT OUTPUT_STRIP_TRAILING_WHITESPACE) endif() string(REGEX REPLACE "[ ]*\n" "; " CXX_VERSION_RESULT "${CXX_VERSION_RESULT}") -message(STATUS "Compiler: ${CXX_VERSION_RESULT}") +message(STATUS "Compiler: ${CXX_VERSION_RESULT}, ${CMAKE_CXX_COMPILE_FEATURES}") diff --git a/include/nlohmann/detail/conversions/from_json.hpp b/include/nlohmann/detail/conversions/from_json.hpp index 578a57c3eb..5c79a67e5b 100644 --- a/include/nlohmann/detail/conversions/from_json.hpp +++ b/include/nlohmann/detail/conversions/from_json.hpp @@ -19,7 +19,7 @@ #include #include -#ifdef JSON_HAS_CPP_17 +#ifdef JSON_STD_FILESYSTEM_EXPERIMENTAL #if JSON_STD_FILESYSTEM_EXPERIMENTAL #include namespace nlohmann::detail @@ -460,7 +460,7 @@ void from_json(const BasicJsonType& j, std::unordered_map void from_json(const BasicJsonType& j, std_fs::path& p) { diff --git a/include/nlohmann/detail/conversions/to_json.hpp b/include/nlohmann/detail/conversions/to_json.hpp index f53b566e1d..7fc5a05ef3 100644 --- a/include/nlohmann/detail/conversions/to_json.hpp +++ b/include/nlohmann/detail/conversions/to_json.hpp @@ -15,7 +15,7 @@ #include #include -#ifdef JSON_HAS_CPP_17 +#ifdef JSON_STD_FILESYSTEM_EXPERIMENTAL #if JSON_STD_FILESYSTEM_EXPERIMENTAL #include namespace nlohmann::detail @@ -403,7 +403,7 @@ void to_json(BasicJsonType& j, const T& t) to_json_tuple_impl(j, t, make_index_sequence::value> {}); } -#ifdef JSON_HAS_CPP_17 +#ifdef JSON_STD_FILESYSTEM_EXPERIMENTAL template void to_json(BasicJsonType& j, const std_fs::path& p) { diff --git a/include/nlohmann/detail/macro_scope.hpp b/include/nlohmann/detail/macro_scope.hpp index f080db195f..22c0ea5251 100644 --- a/include/nlohmann/detail/macro_scope.hpp +++ b/include/nlohmann/detail/macro_scope.hpp @@ -52,6 +52,11 @@ #else #define JSON_STD_FILESYSTEM_EXPERIMENTAL 0 #endif + + // std::filesystem does not work on MinGW GCC 8: https://sourceforge.net/p/mingw-w64/bugs/737/ + #if __MINGW32__ && __GNUC__ == 8 + #undef JSON_STD_FILESYSTEM_EXPERIMENTAL + #endif #endif // disable documentation warnings on clang diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 32dd5e1c6c..7e758f05fe 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -2340,6 +2340,11 @@ using is_detected_convertible = #else #define JSON_STD_FILESYSTEM_EXPERIMENTAL 0 #endif + + // std::filesystem does not work on MinGW GCC 8: https://sourceforge.net/p/mingw-w64/bugs/737/ + #if __MINGW32__ && __GNUC__ == 8 + #undef JSON_STD_FILESYSTEM_EXPERIMENTAL + #endif #endif // disable documentation warnings on clang @@ -3967,7 +3972,7 @@ T conditional_static_cast(U value) // #include -#ifdef JSON_HAS_CPP_17 +#ifdef JSON_STD_FILESYSTEM_EXPERIMENTAL #if JSON_STD_FILESYSTEM_EXPERIMENTAL #include namespace nlohmann::detail @@ -4408,7 +4413,7 @@ void from_json(const BasicJsonType& j, std::unordered_map void from_json(const BasicJsonType& j, std_fs::path& p) { @@ -4655,7 +4660,7 @@ class tuple_element> // #include -#ifdef JSON_HAS_CPP_17 +#ifdef JSON_STD_FILESYSTEM_EXPERIMENTAL #if JSON_STD_FILESYSTEM_EXPERIMENTAL #include namespace nlohmann::detail @@ -5043,7 +5048,7 @@ void to_json(BasicJsonType& j, const T& t) to_json_tuple_impl(j, t, make_index_sequence::value> {}); } -#ifdef JSON_HAS_CPP_17 +#ifdef JSON_STD_FILESYSTEM_EXPERIMENTAL template void to_json(BasicJsonType& j, const std_fs::path& p) { diff --git a/test/src/unit-regression2.cpp b/test/src/unit-regression2.cpp index 158e277485..807e27f14b 100644 --- a/test/src/unit-regression2.cpp +++ b/test/src/unit-regression2.cpp @@ -62,6 +62,11 @@ using ordered_json = nlohmann::ordered_json; #define JSON_STD_FILESYSTEM_EXPERIMENTAL 1 #else #define JSON_STD_FILESYSTEM_EXPERIMENTAL 0 + + // std::filesystem does not work on MinGW GCC 8: https://sourceforge.net/p/mingw-w64/bugs/737/ + #if __MINGW32__ && __GNUC__ == 8 + #undef JSON_STD_FILESYSTEM_EXPERIMENTAL + #endif #endif #if JSON_STD_FILESYSTEM_EXPERIMENTAL @@ -379,9 +384,7 @@ TEST_CASE("regression tests 2") #ifdef JSON_HAS_CPP_17 SECTION("issue #1292 - Serializing std::variant causes stack overflow") { - static_assert( - !std::is_constructible>::value, - ""); + static_assert(!std::is_constructible>::value, "unexpected value"); } #endif @@ -756,7 +759,7 @@ TEST_CASE("regression tests 2") CHECK(j == k); } -#ifdef JSON_HAS_CPP_17 +#ifdef JSON_STD_FILESYSTEM_EXPERIMENTAL SECTION("issue #3070 - Version 3.10.3 breaks backward-compatibility with 3.10.2 ") { nlohmann::detail::std_fs::path text_path("/tmp/text.txt"); From 5cd67e7d2336816ad7029f93566667a8caab5d7f Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Wed, 20 Oct 2021 15:03:50 +0200 Subject: [PATCH 08/38] :alembic: use proper header for filesystem --- test/src/unit-regression2.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/src/unit-regression2.cpp b/test/src/unit-regression2.cpp index 807e27f14b..fb8b268c6d 100644 --- a/test/src/unit-regression2.cpp +++ b/test/src/unit-regression2.cpp @@ -69,6 +69,7 @@ using ordered_json = nlohmann::ordered_json; #endif #endif +#ifdef JSON_STD_FILESYSTEM_EXPERIMENTAL #if JSON_STD_FILESYSTEM_EXPERIMENTAL #include namespace nlohmann::detail @@ -83,6 +84,7 @@ namespace std_fs = std::filesystem; } // namespace nlohmann::detail #endif #endif +#endif #ifdef JSON_HAS_CPP_20 #include From 12bb88871e3cc4f52b3bc488ddc73389a7ac3b55 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Wed, 20 Oct 2021 15:18:00 +0200 Subject: [PATCH 09/38] :alembic: do not use too old compilers with C++17 --- include/nlohmann/detail/macro_scope.hpp | 2 +- single_include/nlohmann/json.hpp | 2 +- test/CMakeLists.txt | 4 ++++ test/src/unit-regression2.cpp | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/include/nlohmann/detail/macro_scope.hpp b/include/nlohmann/detail/macro_scope.hpp index 22c0ea5251..e113ea5735 100644 --- a/include/nlohmann/detail/macro_scope.hpp +++ b/include/nlohmann/detail/macro_scope.hpp @@ -54,7 +54,7 @@ #endif // std::filesystem does not work on MinGW GCC 8: https://sourceforge.net/p/mingw-w64/bugs/737/ - #if __MINGW32__ && __GNUC__ == 8 + #if defined(__MINGW32__) && defined(__GNUC__) && __GNUC__ == 8 #undef JSON_STD_FILESYSTEM_EXPERIMENTAL #endif #endif diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 7e758f05fe..4cb0056e55 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -2342,7 +2342,7 @@ using is_detected_convertible = #endif // std::filesystem does not work on MinGW GCC 8: https://sourceforge.net/p/mingw-w64/bugs/737/ - #if __MINGW32__ && __GNUC__ == 8 + #if defined(__MINGW32__) && defined(__GNUC__) && __GNUC__ == 8 #undef JSON_STD_FILESYSTEM_EXPERIMENTAL #endif #endif diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 5f681e5d00..0ab0210518 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -58,6 +58,10 @@ foreach(feature ${CMAKE_CXX_COMPILE_FEATURES}) set(compiler_supports_cpp_17 TRUE) endif() endforeach() +# Clang only supports C++17 starting from Clang 5.0 +if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0) + unset(compiler_supports_cpp_17) +endif() file(GLOB files src/unit-*.cpp) diff --git a/test/src/unit-regression2.cpp b/test/src/unit-regression2.cpp index fb8b268c6d..292f5f04a5 100644 --- a/test/src/unit-regression2.cpp +++ b/test/src/unit-regression2.cpp @@ -64,7 +64,7 @@ using ordered_json = nlohmann::ordered_json; #define JSON_STD_FILESYSTEM_EXPERIMENTAL 0 // std::filesystem does not work on MinGW GCC 8: https://sourceforge.net/p/mingw-w64/bugs/737/ - #if __MINGW32__ && __GNUC__ == 8 + #if defined(__MINGW32__) && defined(__GNUC__) && __GNUC__ == 8 #undef JSON_STD_FILESYSTEM_EXPERIMENTAL #endif #endif From 2b431c212f9fecce29c14d75a91ede8c9d06ed79 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Wed, 20 Oct 2021 19:14:48 +0200 Subject: [PATCH 10/38] :alembic: do not use too old compilers with C++17 --- .../nlohmann/detail/conversions/from_json.hpp | 8 ++-- .../nlohmann/detail/conversions/to_json.hpp | 8 ++-- include/nlohmann/detail/macro_scope.hpp | 24 +++++++---- include/nlohmann/detail/macro_unscope.hpp | 3 +- single_include/nlohmann/json.hpp | 43 ++++++++++--------- test/src/unit-regression2.cpp | 38 ++++++++-------- 6 files changed, 64 insertions(+), 60 deletions(-) diff --git a/include/nlohmann/detail/conversions/from_json.hpp b/include/nlohmann/detail/conversions/from_json.hpp index 5c79a67e5b..207d3e3024 100644 --- a/include/nlohmann/detail/conversions/from_json.hpp +++ b/include/nlohmann/detail/conversions/from_json.hpp @@ -19,21 +19,19 @@ #include #include -#ifdef JSON_STD_FILESYSTEM_EXPERIMENTAL -#if JSON_STD_FILESYSTEM_EXPERIMENTAL +#if JSON_HAS_EXPERIMENTAL_FILESYSTEM #include namespace nlohmann::detail { namespace std_fs = std::experimental::filesystem; } // namespace nlohmann::detail -#else +#elif JSON_HAS_FILESYSTEM #include namespace nlohmann::detail { namespace std_fs = std::filesystem; } // namespace nlohmann::detail #endif -#endif namespace nlohmann { @@ -460,7 +458,7 @@ void from_json(const BasicJsonType& j, std::unordered_map void from_json(const BasicJsonType& j, std_fs::path& p) { diff --git a/include/nlohmann/detail/conversions/to_json.hpp b/include/nlohmann/detail/conversions/to_json.hpp index 7fc5a05ef3..7628ae0116 100644 --- a/include/nlohmann/detail/conversions/to_json.hpp +++ b/include/nlohmann/detail/conversions/to_json.hpp @@ -15,21 +15,19 @@ #include #include -#ifdef JSON_STD_FILESYSTEM_EXPERIMENTAL -#if JSON_STD_FILESYSTEM_EXPERIMENTAL +#if JSON_HAS_EXPERIMENTAL_FILESYSTEM #include namespace nlohmann::detail { namespace std_fs = std::experimental::filesystem; } // namespace nlohmann::detail -#else +#elif JSON_HAS_FILESYSTEM #include namespace nlohmann::detail { namespace std_fs = std::filesystem; } // namespace nlohmann::detail #endif -#endif namespace nlohmann { @@ -403,7 +401,7 @@ void to_json(BasicJsonType& j, const T& t) to_json_tuple_impl(j, t, make_index_sequence::value> {}); } -#ifdef JSON_STD_FILESYSTEM_EXPERIMENTAL +#if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM template void to_json(BasicJsonType& j, const std_fs::path& p) { diff --git a/include/nlohmann/detail/macro_scope.hpp b/include/nlohmann/detail/macro_scope.hpp index e113ea5735..00f197b634 100644 --- a/include/nlohmann/detail/macro_scope.hpp +++ b/include/nlohmann/detail/macro_scope.hpp @@ -38,27 +38,33 @@ #endif #ifdef JSON_HAS_CPP_17 - // set JSON_STD_FILESYSTEM_EXPERIMENTAL to 1 if should be taken instead of #if defined(__cpp_lib_filesystem) - #define JSON_STD_FILESYSTEM_EXPERIMENTAL 0 + #define JSON_HAS_FILESYSTEM 1 #elif defined(__cpp_lib_experimental_filesystem) - #define JSON_STD_FILESYSTEM_EXPERIMENTAL 1 + #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1 #elif !defined(__has_include) - #define JSON_STD_FILESYSTEM_EXPERIMENTAL 1 + #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1 #elif __has_include() - #define JSON_STD_FILESYSTEM_EXPERIMENTAL 0 + #define JSON_HAS_FILESYSTEM 1 #elif __has_include() - #define JSON_STD_FILESYSTEM_EXPERIMENTAL 1 - #else - #define JSON_STD_FILESYSTEM_EXPERIMENTAL 0 + #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1 #endif // std::filesystem does not work on MinGW GCC 8: https://sourceforge.net/p/mingw-w64/bugs/737/ #if defined(__MINGW32__) && defined(__GNUC__) && __GNUC__ == 8 - #undef JSON_STD_FILESYSTEM_EXPERIMENTAL + #undef JSON_HAS_FILESYSTEM + #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM #endif #endif +#ifndef JSON_HAS_EXPERIMENTAL_FILESYSTEM + #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 0 +#endif + +#ifndef JSON_HAS_FILESYSTEM + #define JSON_HAS_FILESYSTEM 0 +#endif + // disable documentation warnings on clang #if defined(__clang__) #pragma clang diagnostic push diff --git a/include/nlohmann/detail/macro_unscope.hpp b/include/nlohmann/detail/macro_unscope.hpp index e0cc5dc40a..1a29fb5e00 100644 --- a/include/nlohmann/detail/macro_unscope.hpp +++ b/include/nlohmann/detail/macro_unscope.hpp @@ -16,7 +16,8 @@ #undef JSON_HAS_CPP_14 #undef JSON_HAS_CPP_17 #undef JSON_HAS_CPP_20 -#undef JSON_STD_FILESYSTEM_EXPERIMENTAL +#undef JSON_HAS_FILESYSTEM +#undef JSON_HAS_EXPERIMENTAL_FILESYSTEM #undef NLOHMANN_BASIC_JSON_TPL_DECLARATION #undef NLOHMANN_BASIC_JSON_TPL #undef JSON_EXPLICIT diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 4cb0056e55..ae187d1fd7 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -2326,27 +2326,33 @@ using is_detected_convertible = #endif #ifdef JSON_HAS_CPP_17 - // set JSON_STD_FILESYSTEM_EXPERIMENTAL to 1 if should be taken instead of #if defined(__cpp_lib_filesystem) - #define JSON_STD_FILESYSTEM_EXPERIMENTAL 0 + #define JSON_HAS_FILESYSTEM 1 #elif defined(__cpp_lib_experimental_filesystem) - #define JSON_STD_FILESYSTEM_EXPERIMENTAL 1 + #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1 #elif !defined(__has_include) - #define JSON_STD_FILESYSTEM_EXPERIMENTAL 1 + #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1 #elif __has_include() - #define JSON_STD_FILESYSTEM_EXPERIMENTAL 0 + #define JSON_HAS_FILESYSTEM 1 #elif __has_include() - #define JSON_STD_FILESYSTEM_EXPERIMENTAL 1 - #else - #define JSON_STD_FILESYSTEM_EXPERIMENTAL 0 + #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1 #endif // std::filesystem does not work on MinGW GCC 8: https://sourceforge.net/p/mingw-w64/bugs/737/ #if defined(__MINGW32__) && defined(__GNUC__) && __GNUC__ == 8 - #undef JSON_STD_FILESYSTEM_EXPERIMENTAL + #undef JSON_HAS_FILESYSTEM + #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM #endif #endif +#ifndef JSON_HAS_EXPERIMENTAL_FILESYSTEM + #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 0 +#endif + +#ifndef JSON_HAS_FILESYSTEM + #define JSON_HAS_FILESYSTEM 0 +#endif + // disable documentation warnings on clang #if defined(__clang__) #pragma clang diagnostic push @@ -3972,21 +3978,19 @@ T conditional_static_cast(U value) // #include -#ifdef JSON_STD_FILESYSTEM_EXPERIMENTAL -#if JSON_STD_FILESYSTEM_EXPERIMENTAL +#if JSON_HAS_EXPERIMENTAL_FILESYSTEM #include namespace nlohmann::detail { namespace std_fs = std::experimental::filesystem; } // namespace nlohmann::detail -#else +#elif JSON_HAS_FILESYSTEM #include namespace nlohmann::detail { namespace std_fs = std::filesystem; } // namespace nlohmann::detail #endif -#endif namespace nlohmann { @@ -4413,7 +4417,7 @@ void from_json(const BasicJsonType& j, std::unordered_map void from_json(const BasicJsonType& j, std_fs::path& p) { @@ -4660,21 +4664,19 @@ class tuple_element> // #include -#ifdef JSON_STD_FILESYSTEM_EXPERIMENTAL -#if JSON_STD_FILESYSTEM_EXPERIMENTAL +#if JSON_HAS_EXPERIMENTAL_FILESYSTEM #include namespace nlohmann::detail { namespace std_fs = std::experimental::filesystem; } // namespace nlohmann::detail -#else +#elif JSON_HAS_FILESYSTEM #include namespace nlohmann::detail { namespace std_fs = std::filesystem; } // namespace nlohmann::detail #endif -#endif namespace nlohmann { @@ -5048,7 +5050,7 @@ void to_json(BasicJsonType& j, const T& t) to_json_tuple_impl(j, t, make_index_sequence::value> {}); } -#ifdef JSON_STD_FILESYSTEM_EXPERIMENTAL +#if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM template void to_json(BasicJsonType& j, const std_fs::path& p) { @@ -26637,7 +26639,8 @@ inline nlohmann::json::json_pointer operator "" _json_pointer(const char* s, std #undef JSON_HAS_CPP_14 #undef JSON_HAS_CPP_17 #undef JSON_HAS_CPP_20 -#undef JSON_STD_FILESYSTEM_EXPERIMENTAL +#undef JSON_HAS_FILESYSTEM +#undef JSON_HAS_EXPERIMENTAL_FILESYSTEM #undef NLOHMANN_BASIC_JSON_TPL_DECLARATION #undef NLOHMANN_BASIC_JSON_TPL #undef JSON_EXPLICIT diff --git a/test/src/unit-regression2.cpp b/test/src/unit-regression2.cpp index 292f5f04a5..fa0ca3a0e6 100644 --- a/test/src/unit-regression2.cpp +++ b/test/src/unit-regression2.cpp @@ -49,42 +49,40 @@ 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 +#ifdef JSON_HAS_CPP_17 + #if defined(__cpp_lib_filesystem) + #define JSON_HAS_FILESYSTEM 1 + #elif defined(__cpp_lib_experimental_filesystem) + #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1 + #elif !defined(__has_include) + #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1 + #elif __has_include() + #define JSON_HAS_FILESYSTEM 1 + #elif __has_include() + #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1 + #endif // std::filesystem does not work on MinGW GCC 8: https://sourceforge.net/p/mingw-w64/bugs/737/ #if defined(__MINGW32__) && defined(__GNUC__) && __GNUC__ == 8 - #undef JSON_STD_FILESYSTEM_EXPERIMENTAL + #undef JSON_HAS_FILESYSTEM + #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM #endif #endif -#ifdef JSON_STD_FILESYSTEM_EXPERIMENTAL -#if JSON_STD_FILESYSTEM_EXPERIMENTAL +#if JSON_HAS_EXPERIMENTAL_FILESYSTEM #include namespace nlohmann::detail { namespace std_fs = std::experimental::filesystem; } // namespace nlohmann::detail -#else +#elif JSON_HAS_FILESYSTEM #include namespace nlohmann::detail { namespace std_fs = std::filesystem; } // namespace nlohmann::detail #endif -#endif -#endif + #ifdef JSON_HAS_CPP_20 #include @@ -761,7 +759,7 @@ TEST_CASE("regression tests 2") CHECK(j == k); } -#ifdef JSON_STD_FILESYSTEM_EXPERIMENTAL +#if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM SECTION("issue #3070 - Version 3.10.3 breaks backward-compatibility with 3.10.2 ") { nlohmann::detail::std_fs::path text_path("/tmp/text.txt"); From 7543e179efc5e470533efdf836df4112021df8da Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Wed, 20 Oct 2021 19:23:05 +0200 Subject: [PATCH 11/38] :alembic: do not use too old compilers with C++17 --- test/src/unit-regression2.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/src/unit-regression2.cpp b/test/src/unit-regression2.cpp index fa0ca3a0e6..237d8e9046 100644 --- a/test/src/unit-regression2.cpp +++ b/test/src/unit-regression2.cpp @@ -47,9 +47,8 @@ using ordered_json = nlohmann::ordered_json; #endif #ifdef JSON_HAS_CPP_17 -#include + #include -#ifdef JSON_HAS_CPP_17 #if defined(__cpp_lib_filesystem) #define JSON_HAS_FILESYSTEM 1 #elif defined(__cpp_lib_experimental_filesystem) From 7e87863a6ddcf076b7b8728f4f57aca128b5e32c Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Wed, 20 Oct 2021 20:23:54 +0200 Subject: [PATCH 12/38] :rotating_light: fix warning --- doc/mkdocs/docs/features/macros.md | 7 +++++ include/nlohmann/detail/macro_scope.hpp | 34 +++++++++++---------- single_include/nlohmann/json.hpp | 34 +++++++++++---------- test/src/unit-regression2.cpp | 40 +++++++++++++++---------- 4 files changed, 68 insertions(+), 47 deletions(-) diff --git a/doc/mkdocs/docs/features/macros.md b/doc/mkdocs/docs/features/macros.md index 8b10ef1f35..bf279a139d 100644 --- a/doc/mkdocs/docs/features/macros.md +++ b/doc/mkdocs/docs/features/macros.md @@ -24,6 +24,13 @@ The diagnostics messages can also be controlled with the CMake option `JSON_Diag The library targets C++11, but also supports some features introduced in later C++ versions (e.g., `std::string_view` support for C++17). For these new features, the library implements some preprocessor checks to determine the C++ standard. By defining any of these symbols, the internal check is overridden and the provided C++ version is unconditionally assumed. This can be helpful for compilers that only implement parts of the standard and would be detected incorrectly. +## `JSON_HAS_FILESYSTEM`, `JSON_HAS_EXPERIMENTAL_FILESYSTEM` + +When compiling with C++17, the library provides conversions from and to `std::filesystem::path`. As compiler support +for filesystem is limited, the library tries to detect whether ``/`std::filesystem` (`JSON_HAS_FILESYSTEM`) +or ``/`std::experimental::filesystem` (`JSON_HAS_EXPERIMENTAL_FILESYSTEM`) should be used. +To override the built-in check, define `JSON_HAS_FILESYSTEM` or `JSON_HAS_EXPERIMENTAL_FILESYSTEM` to `1`. + ## `JSON_NOEXCEPTION` Exceptions can be switched off by defining the symbol `JSON_NOEXCEPTION`. diff --git a/include/nlohmann/detail/macro_scope.hpp b/include/nlohmann/detail/macro_scope.hpp index 00f197b634..83d8e06b45 100644 --- a/include/nlohmann/detail/macro_scope.hpp +++ b/include/nlohmann/detail/macro_scope.hpp @@ -37,23 +37,25 @@ #define JSON_HAS_CPP_11 #endif -#ifdef JSON_HAS_CPP_17 - #if defined(__cpp_lib_filesystem) - #define JSON_HAS_FILESYSTEM 1 - #elif defined(__cpp_lib_experimental_filesystem) - #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1 - #elif !defined(__has_include) - #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1 - #elif __has_include() - #define JSON_HAS_FILESYSTEM 1 - #elif __has_include() - #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1 - #endif +#if !defined(JSON_HAS_FILESYSTEM) && !defined(JSON_HAS_EXPERIMENTAL_FILESYSTEM) + #ifdef JSON_HAS_CPP_17 + #if defined(__cpp_lib_filesystem) + #define JSON_HAS_FILESYSTEM 1 + #elif defined(__cpp_lib_experimental_filesystem) + #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1 + #elif !defined(__has_include) + #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1 + #elif __has_include() + #define JSON_HAS_FILESYSTEM 1 + #elif __has_include() + #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1 + #endif - // std::filesystem does not work on MinGW GCC 8: https://sourceforge.net/p/mingw-w64/bugs/737/ - #if defined(__MINGW32__) && defined(__GNUC__) && __GNUC__ == 8 - #undef JSON_HAS_FILESYSTEM - #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM + // std::filesystem does not work on MinGW GCC 8: https://sourceforge.net/p/mingw-w64/bugs/737/ + #if defined(__MINGW32__) && defined(__GNUC__) && __GNUC__ == 8 + #undef JSON_HAS_FILESYSTEM + #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM + #endif #endif #endif diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index ae187d1fd7..5be8bfa5d0 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -2325,23 +2325,25 @@ using is_detected_convertible = #define JSON_HAS_CPP_11 #endif -#ifdef JSON_HAS_CPP_17 - #if defined(__cpp_lib_filesystem) - #define JSON_HAS_FILESYSTEM 1 - #elif defined(__cpp_lib_experimental_filesystem) - #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1 - #elif !defined(__has_include) - #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1 - #elif __has_include() - #define JSON_HAS_FILESYSTEM 1 - #elif __has_include() - #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1 - #endif +#if !defined(JSON_HAS_FILESYSTEM) && !defined(JSON_HAS_EXPERIMENTAL_FILESYSTEM) + #ifdef JSON_HAS_CPP_17 + #if defined(__cpp_lib_filesystem) + #define JSON_HAS_FILESYSTEM 1 + #elif defined(__cpp_lib_experimental_filesystem) + #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1 + #elif !defined(__has_include) + #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1 + #elif __has_include() + #define JSON_HAS_FILESYSTEM 1 + #elif __has_include() + #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1 + #endif - // std::filesystem does not work on MinGW GCC 8: https://sourceforge.net/p/mingw-w64/bugs/737/ - #if defined(__MINGW32__) && defined(__GNUC__) && __GNUC__ == 8 - #undef JSON_HAS_FILESYSTEM - #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM + // std::filesystem does not work on MinGW GCC 8: https://sourceforge.net/p/mingw-w64/bugs/737/ + #if defined(__MINGW32__) && defined(__GNUC__) && __GNUC__ == 8 + #undef JSON_HAS_FILESYSTEM + #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM + #endif #endif #endif diff --git a/test/src/unit-regression2.cpp b/test/src/unit-regression2.cpp index 237d8e9046..22c0154d33 100644 --- a/test/src/unit-regression2.cpp +++ b/test/src/unit-regression2.cpp @@ -49,23 +49,33 @@ using ordered_json = nlohmann::ordered_json; #ifdef JSON_HAS_CPP_17 #include - #if defined(__cpp_lib_filesystem) - #define JSON_HAS_FILESYSTEM 1 - #elif defined(__cpp_lib_experimental_filesystem) - #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1 - #elif !defined(__has_include) - #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1 - #elif __has_include() - #define JSON_HAS_FILESYSTEM 1 - #elif __has_include() - #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1 + #if !defined(JSON_HAS_FILESYSTEM) && !defined(JSON_HAS_EXPERIMENTAL_FILESYSTEM) + #if defined(__cpp_lib_filesystem) + #define JSON_HAS_FILESYSTEM 1 + #elif defined(__cpp_lib_experimental_filesystem) + #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1 + #elif !defined(__has_include) + #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1 + #elif __has_include() + #define JSON_HAS_FILESYSTEM 1 + #elif __has_include() + #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1 + #endif + + // std::filesystem does not work on MinGW GCC 8: https://sourceforge.net/p/mingw-w64/bugs/737/ + #if defined(__MINGW32__) && defined(__GNUC__) && __GNUC__ == 8 + #undef JSON_HAS_FILESYSTEM + #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM + #endif #endif +#endif - // std::filesystem does not work on MinGW GCC 8: https://sourceforge.net/p/mingw-w64/bugs/737/ - #if defined(__MINGW32__) && defined(__GNUC__) && __GNUC__ == 8 - #undef JSON_HAS_FILESYSTEM - #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM - #endif +#ifndef JSON_HAS_EXPERIMENTAL_FILESYSTEM + #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 0 +#endif + +#ifndef JSON_HAS_FILESYSTEM + #define JSON_HAS_FILESYSTEM 0 #endif #if JSON_HAS_EXPERIMENTAL_FILESYSTEM From 4c10ccafd94eb2348fb1e641d65e070aad3cfa7f Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Wed, 20 Oct 2021 20:35:07 +0200 Subject: [PATCH 13/38] :hammer: cleanup --- cmake/download_test_data.cmake | 2 +- include/nlohmann/detail/macro_scope.hpp | 10 +++++----- single_include/nlohmann/json.hpp | 10 +++++----- test/CMakeLists.txt | 6 +++--- test/src/unit-regression2.cpp | 10 +++++----- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/cmake/download_test_data.cmake b/cmake/download_test_data.cmake index d2763147c7..f516a7c3b2 100644 --- a/cmake/download_test_data.cmake +++ b/cmake/download_test_data.cmake @@ -53,4 +53,4 @@ else() execute_process(COMMAND ${CMAKE_CXX_COMPILER} --version OUTPUT_VARIABLE CXX_VERSION_RESULT OUTPUT_STRIP_TRAILING_WHITESPACE) endif() string(REGEX REPLACE "[ ]*\n" "; " CXX_VERSION_RESULT "${CXX_VERSION_RESULT}") -message(STATUS "Compiler: ${CXX_VERSION_RESULT}, ${CMAKE_CXX_COMPILE_FEATURES}") +message(STATUS "Compiler: ${CXX_VERSION_RESULT}") diff --git a/include/nlohmann/detail/macro_scope.hpp b/include/nlohmann/detail/macro_scope.hpp index 83d8e06b45..040e1b9a21 100644 --- a/include/nlohmann/detail/macro_scope.hpp +++ b/include/nlohmann/detail/macro_scope.hpp @@ -51,11 +51,11 @@ #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1 #endif - // std::filesystem does not work on MinGW GCC 8: https://sourceforge.net/p/mingw-w64/bugs/737/ - #if defined(__MINGW32__) && defined(__GNUC__) && __GNUC__ == 8 - #undef JSON_HAS_FILESYSTEM - #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM - #endif + //// std::filesystem does not work on MinGW GCC 8: https://sourceforge.net/p/mingw-w64/bugs/737/ + //#if defined(__MINGW32__) && defined(__GNUC__) && __GNUC__ == 8 + // #undef JSON_HAS_FILESYSTEM + // #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM + //#endif #endif #endif diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 5be8bfa5d0..72be1389b1 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -2339,11 +2339,11 @@ using is_detected_convertible = #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1 #endif - // std::filesystem does not work on MinGW GCC 8: https://sourceforge.net/p/mingw-w64/bugs/737/ - #if defined(__MINGW32__) && defined(__GNUC__) && __GNUC__ == 8 - #undef JSON_HAS_FILESYSTEM - #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM - #endif + //// std::filesystem does not work on MinGW GCC 8: https://sourceforge.net/p/mingw-w64/bugs/737/ + //#if defined(__MINGW32__) && defined(__GNUC__) && __GNUC__ == 8 + // #undef JSON_HAS_FILESYSTEM + // #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM + //#endif #endif #endif diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 0ab0210518..197fb11ee5 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -59,9 +59,9 @@ foreach(feature ${CMAKE_CXX_COMPILE_FEATURES}) endif() endforeach() # Clang only supports C++17 starting from Clang 5.0 -if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0) - unset(compiler_supports_cpp_17) -endif() +#if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0) +# unset(compiler_supports_cpp_17) +#endif() file(GLOB files src/unit-*.cpp) diff --git a/test/src/unit-regression2.cpp b/test/src/unit-regression2.cpp index 22c0154d33..5e0f8f804a 100644 --- a/test/src/unit-regression2.cpp +++ b/test/src/unit-regression2.cpp @@ -62,11 +62,11 @@ using ordered_json = nlohmann::ordered_json; #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1 #endif - // std::filesystem does not work on MinGW GCC 8: https://sourceforge.net/p/mingw-w64/bugs/737/ - #if defined(__MINGW32__) && defined(__GNUC__) && __GNUC__ == 8 - #undef JSON_HAS_FILESYSTEM - #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM - #endif + //// std::filesystem does not work on MinGW GCC 8: https://sourceforge.net/p/mingw-w64/bugs/737/ + //#if defined(__MINGW32__) && defined(__GNUC__) && __GNUC__ == 8 + // #undef JSON_HAS_FILESYSTEM + // #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM + //#endif #endif #endif From ccd42cd3ac6e85b67e558611087fb21b55571d84 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Wed, 20 Oct 2021 21:54:09 +0200 Subject: [PATCH 14/38] :rewind: undo cleanup --- include/nlohmann/detail/macro_scope.hpp | 10 +++++----- single_include/nlohmann/json.hpp | 10 +++++----- test/CMakeLists.txt | 6 +++--- test/src/unit-regression2.cpp | 10 +++++----- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/include/nlohmann/detail/macro_scope.hpp b/include/nlohmann/detail/macro_scope.hpp index 040e1b9a21..83d8e06b45 100644 --- a/include/nlohmann/detail/macro_scope.hpp +++ b/include/nlohmann/detail/macro_scope.hpp @@ -51,11 +51,11 @@ #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1 #endif - //// std::filesystem does not work on MinGW GCC 8: https://sourceforge.net/p/mingw-w64/bugs/737/ - //#if defined(__MINGW32__) && defined(__GNUC__) && __GNUC__ == 8 - // #undef JSON_HAS_FILESYSTEM - // #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM - //#endif + // std::filesystem does not work on MinGW GCC 8: https://sourceforge.net/p/mingw-w64/bugs/737/ + #if defined(__MINGW32__) && defined(__GNUC__) && __GNUC__ == 8 + #undef JSON_HAS_FILESYSTEM + #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM + #endif #endif #endif diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 72be1389b1..5be8bfa5d0 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -2339,11 +2339,11 @@ using is_detected_convertible = #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1 #endif - //// std::filesystem does not work on MinGW GCC 8: https://sourceforge.net/p/mingw-w64/bugs/737/ - //#if defined(__MINGW32__) && defined(__GNUC__) && __GNUC__ == 8 - // #undef JSON_HAS_FILESYSTEM - // #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM - //#endif + // std::filesystem does not work on MinGW GCC 8: https://sourceforge.net/p/mingw-w64/bugs/737/ + #if defined(__MINGW32__) && defined(__GNUC__) && __GNUC__ == 8 + #undef JSON_HAS_FILESYSTEM + #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM + #endif #endif #endif diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 197fb11ee5..0ab0210518 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -59,9 +59,9 @@ foreach(feature ${CMAKE_CXX_COMPILE_FEATURES}) endif() endforeach() # Clang only supports C++17 starting from Clang 5.0 -#if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0) -# unset(compiler_supports_cpp_17) -#endif() +if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0) + unset(compiler_supports_cpp_17) +endif() file(GLOB files src/unit-*.cpp) diff --git a/test/src/unit-regression2.cpp b/test/src/unit-regression2.cpp index 5e0f8f804a..22c0154d33 100644 --- a/test/src/unit-regression2.cpp +++ b/test/src/unit-regression2.cpp @@ -62,11 +62,11 @@ using ordered_json = nlohmann::ordered_json; #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1 #endif - //// std::filesystem does not work on MinGW GCC 8: https://sourceforge.net/p/mingw-w64/bugs/737/ - //#if defined(__MINGW32__) && defined(__GNUC__) && __GNUC__ == 8 - // #undef JSON_HAS_FILESYSTEM - // #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM - //#endif + // std::filesystem does not work on MinGW GCC 8: https://sourceforge.net/p/mingw-w64/bugs/737/ + #if defined(__MINGW32__) && defined(__GNUC__) && __GNUC__ == 8 + #undef JSON_HAS_FILESYSTEM + #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM + #endif #endif #endif From d300856292e2ca5c381805c5ae35fb6e22db6cd5 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Thu, 21 Oct 2021 07:43:52 +0200 Subject: [PATCH 15/38] :white_check_mark: add test --- test/CMakeLists.txt | 4 ++++ test/src/unit-regression2.cpp | 2 ++ 2 files changed, 6 insertions(+) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 0ab0210518..ab598878ba 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -62,6 +62,10 @@ endforeach() if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0) unset(compiler_supports_cpp_17) endif() +# MSVC 2015 (14.0) does not support C++17 +if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.1) + unset(compiler_supports_cpp_17) +endif() file(GLOB files src/unit-*.cpp) diff --git a/test/src/unit-regression2.cpp b/test/src/unit-regression2.cpp index 22c0154d33..0d625f0385 100644 --- a/test/src/unit-regression2.cpp +++ b/test/src/unit-regression2.cpp @@ -776,6 +776,8 @@ TEST_CASE("regression tests 2") const auto j_path = j.get(); CHECK(j_path == text_path); + + CHECK_THROWS_WITH_AS(nlohmann::detail::std_fs::path(json(1)), "[json.exception.type_error.302] type must be string, but is number", json::type_error); } #endif From 37be287baee359f27ce0e1db0ea5dcd72f0d9e8d Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Thu, 21 Oct 2021 21:56:12 +0200 Subject: [PATCH 16/38] :hammer: add more constraints #3097 --- include/nlohmann/detail/macro_scope.hpp | 30 ++++++++++++++++++++++++ single_include/nlohmann/json.hpp | 30 ++++++++++++++++++++++++ test/src/unit-regression2.cpp | 31 +++++++++++++++++++++++++ 3 files changed, 91 insertions(+) diff --git a/include/nlohmann/detail/macro_scope.hpp b/include/nlohmann/detail/macro_scope.hpp index 83d8e06b45..c954271d2a 100644 --- a/include/nlohmann/detail/macro_scope.hpp +++ b/include/nlohmann/detail/macro_scope.hpp @@ -56,6 +56,36 @@ #undef JSON_HAS_FILESYSTEM #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM #endif + + // no filesystem support before GCC 8: https://en.cppreference.com/w/cpp/compiler_support + #if defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 8 + #undef JSON_HAS_FILESYSTEM + #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM + #endif + + // no filesystem support before Clang 7: https://en.cppreference.com/w/cpp/compiler_support + #if defined(__clang_major__) && __clang_major__ < 7 + #undef JSON_HAS_FILESYSTEM + #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM + #endif + + // no filesystem support before MSVC 19.14: https://en.cppreference.com/w/cpp/compiler_support + #if defined(_MSC_VER) && _MSC_VER < 1940 + #undef JSON_HAS_FILESYSTEM + #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM + #endif + + // no filesystem support before iOS 13 + #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) and __IPHONE_OS_VERSION_MIN_REQUIRED < 130000 + #undef JSON_HAS_FILESYSTEM + #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM + #endif + + // no filesystem support before macOS Catalina + #if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) and __MAC_OS_X_VERSION_MIN_REQUIRED < 101500 + #undef JSON_HAS_FILESYSTEM + #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM + #endif #endif #endif diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 5be8bfa5d0..4b6fb083a6 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -2344,6 +2344,36 @@ using is_detected_convertible = #undef JSON_HAS_FILESYSTEM #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM #endif + + // no filesystem support before GCC 8: https://en.cppreference.com/w/cpp/compiler_support + #if defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 8 + #undef JSON_HAS_FILESYSTEM + #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM + #endif + + // no filesystem support before Clang 7: https://en.cppreference.com/w/cpp/compiler_support + #if defined(__clang_major__) && __clang_major__ < 7 + #undef JSON_HAS_FILESYSTEM + #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM + #endif + + // no filesystem support before MSVC 19.14: https://en.cppreference.com/w/cpp/compiler_support + #if defined(_MSC_VER) && _MSC_VER < 1940 + #undef JSON_HAS_FILESYSTEM + #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM + #endif + + // no filesystem support before iOS 13 + #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) and __IPHONE_OS_VERSION_MIN_REQUIRED < 130000 + #undef JSON_HAS_FILESYSTEM + #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM + #endif + + // no filesystem support before macOS Catalina + #if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) and __MAC_OS_X_VERSION_MIN_REQUIRED < 101500 + #undef JSON_HAS_FILESYSTEM + #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM + #endif #endif #endif diff --git a/test/src/unit-regression2.cpp b/test/src/unit-regression2.cpp index 0d625f0385..f65db7e8cb 100644 --- a/test/src/unit-regression2.cpp +++ b/test/src/unit-regression2.cpp @@ -34,6 +34,7 @@ SOFTWARE. #define JSON_TESTS_PRIVATE #include +#include using json = nlohmann::json; using ordered_json = nlohmann::ordered_json; @@ -67,6 +68,36 @@ using ordered_json = nlohmann::ordered_json; #undef JSON_HAS_FILESYSTEM #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM #endif + + // no filesystem support before GCC 8: https://en.cppreference.com/w/cpp/compiler_support + #if defined(__GNUC__) && __GNUC__ < 8 && !defined(__clang__) + #undef JSON_HAS_FILESYSTEM + #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM + #endif + + // no filesystem support before Clang 7: https://en.cppreference.com/w/cpp/compiler_support + #if defined(__clang_major__) && __clang_major__ < 7 + #undef JSON_HAS_FILESYSTEM + #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM + #endif + + // no filesystem support before MSVC 19.14: https://en.cppreference.com/w/cpp/compiler_support + #if defined(_MSC_VER) && _MSC_VER < 1940 + #undef JSON_HAS_FILESYSTEM + #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM + #endif + + // no filesystem support before iOS 13 + #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) and __IPHONE_OS_VERSION_MIN_REQUIRED < 130000 + #undef JSON_HAS_FILESYSTEM + #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM + #endif + + // no filesystem support before macOS Catalina + #if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) and __MAC_OS_X_VERSION_MIN_REQUIRED < 101500 + #undef JSON_HAS_FILESYSTEM + #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM + #endif #endif #endif From 61829d799e9275db9d9215ccfe45cda7cc9c7a89 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Thu, 21 Oct 2021 22:01:13 +0200 Subject: [PATCH 17/38] :green_heart: remove leftover --- test/src/unit-regression2.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/test/src/unit-regression2.cpp b/test/src/unit-regression2.cpp index f65db7e8cb..62af671792 100644 --- a/test/src/unit-regression2.cpp +++ b/test/src/unit-regression2.cpp @@ -34,7 +34,6 @@ SOFTWARE. #define JSON_TESTS_PRIVATE #include -#include using json = nlohmann::json; using ordered_json = nlohmann::ordered_json; From fed411499f2d480209f5c6efb51fc3700e60ef58 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Thu, 21 Oct 2021 22:08:10 +0200 Subject: [PATCH 18/38] :green_heart: replace "and" with "&&" --- include/nlohmann/detail/macro_scope.hpp | 4 ++-- single_include/nlohmann/json.hpp | 4 ++-- test/src/unit-regression2.cpp | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/nlohmann/detail/macro_scope.hpp b/include/nlohmann/detail/macro_scope.hpp index c954271d2a..8b4f7c0644 100644 --- a/include/nlohmann/detail/macro_scope.hpp +++ b/include/nlohmann/detail/macro_scope.hpp @@ -76,13 +76,13 @@ #endif // no filesystem support before iOS 13 - #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) and __IPHONE_OS_VERSION_MIN_REQUIRED < 130000 + #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED < 130000 #undef JSON_HAS_FILESYSTEM #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM #endif // no filesystem support before macOS Catalina - #if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) and __MAC_OS_X_VERSION_MIN_REQUIRED < 101500 + #if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101500 #undef JSON_HAS_FILESYSTEM #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM #endif diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 4b6fb083a6..7479b03aa5 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -2364,13 +2364,13 @@ using is_detected_convertible = #endif // no filesystem support before iOS 13 - #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) and __IPHONE_OS_VERSION_MIN_REQUIRED < 130000 + #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED < 130000 #undef JSON_HAS_FILESYSTEM #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM #endif // no filesystem support before macOS Catalina - #if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) and __MAC_OS_X_VERSION_MIN_REQUIRED < 101500 + #if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101500 #undef JSON_HAS_FILESYSTEM #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM #endif diff --git a/test/src/unit-regression2.cpp b/test/src/unit-regression2.cpp index 62af671792..3aa5ff94cf 100644 --- a/test/src/unit-regression2.cpp +++ b/test/src/unit-regression2.cpp @@ -87,13 +87,13 @@ using ordered_json = nlohmann::ordered_json; #endif // no filesystem support before iOS 13 - #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) and __IPHONE_OS_VERSION_MIN_REQUIRED < 130000 + #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED < 130000 #undef JSON_HAS_FILESYSTEM #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM #endif // no filesystem support before macOS Catalina - #if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) and __MAC_OS_X_VERSION_MIN_REQUIRED < 101500 + #if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101500 #undef JSON_HAS_FILESYSTEM #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM #endif From 19f75a275e5c8c571f0a4950c461961fa6e349db Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sun, 21 Nov 2021 14:23:45 +0100 Subject: [PATCH 19/38] :rotating_light: suppress modernize-concat-nested-namespaces warning --- .clang-tidy | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.clang-tidy b/.clang-tidy index e936514483..30886d7c8e 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -34,10 +34,11 @@ Checks: '*, -llvmlibc-*, -misc-no-recursion, -misc-non-private-member-variables-in-classes, + -modernize-concat-nested-namespaces, -modernize-use-nodiscard, -modernize-use-trailing-return-type, - -readability-function-size, -readability-function-cognitive-complexity, + -readability-function-size, -readability-identifier-length, -readability-magic-numbers, -readability-redundant-access-specifiers, From 62fe919b5d2ce75131d8422bd0f5b9be414d88ef Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Thu, 23 Dec 2021 22:30:58 +0100 Subject: [PATCH 20/38] :alembic: use fix from https://github.com/nlohmann/json/pull/3101#issuecomment-998788786 --- .github/workflows/ubuntu.yml | 14 +++++++------- cmake/ci.cmake | 6 ++++++ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 13253af057..60aebd1941 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -11,7 +11,7 @@ on: jobs: ci_test_clang: runs-on: ubuntu-latest - container: ghcr.io/nlohmann/json-ci:v2.0.0 + container: ghcr.io/nlohmann/json-ci:main steps: - uses: actions/checkout@v2 - name: cmake @@ -21,7 +21,7 @@ jobs: ci_test_gcc: runs-on: ubuntu-latest - container: ghcr.io/nlohmann/json-ci:v2.0.0 + container: ghcr.io/nlohmann/json-ci:main steps: - uses: actions/checkout@v2 - name: cmake @@ -31,7 +31,7 @@ jobs: ci_static_analysis: runs-on: ubuntu-latest - container: ghcr.io/nlohmann/json-ci:v2.0.0 + container: ghcr.io/nlohmann/json-ci:main strategy: matrix: target: [ci_clang_tidy, ci_cppcheck, ci_test_valgrind, ci_test_clang_sanitizer, ci_test_amalgamation, ci_clang_analyze, ci_cpplint, ci_cmake_flags, ci_single_binaries, ci_reproducible_tests, ci_non_git_tests, ci_offline_testdata, ci_infer] @@ -44,7 +44,7 @@ jobs: ci_cmake_options: runs-on: ubuntu-latest - container: ghcr.io/nlohmann/json-ci:v2.0.0 + container: ghcr.io/nlohmann/json-ci:main strategy: matrix: target: [ci_test_diagnostics, ci_test_noexceptions, ci_test_noimplicitconversions] @@ -57,7 +57,7 @@ jobs: ci_test_coverage: runs-on: ubuntu-latest - container: ghcr.io/nlohmann/json-ci:v2.0.0 + container: ghcr.io/nlohmann/json-ci:main steps: - uses: actions/checkout@v2 - name: cmake @@ -77,7 +77,7 @@ jobs: ci_test_compilers: runs-on: ubuntu-latest - container: ghcr.io/nlohmann/json-ci:v2.0.0 + container: ghcr.io/nlohmann/json-ci:main strategy: matrix: compiler: [g++-4.8, g++-4.9, g++-5, g++-6, g++-7, g++-8, g++-9, g++-10, clang++-3.5, clang++-3.6, clang++-3.7, clang++-3.8, clang++-3.9, clang++-4.0, clang++-5.0, clang++-6.0, clang++-7, clang++-8, clang++-9, clang++-10, clang++-11, clang++-12, clang++-13] @@ -90,7 +90,7 @@ jobs: ci_test_standards: runs-on: ubuntu-latest - container: ghcr.io/nlohmann/json-ci:v2.0.0 + container: ghcr.io/nlohmann/json-ci:main strategy: matrix: standard: [11, 14, 17, 20] diff --git a/cmake/ci.cmake b/cmake/ci.cmake index ce8d2299c0..98a91defb6 100644 --- a/cmake/ci.cmake +++ b/cmake/ci.cmake @@ -814,11 +814,17 @@ add_custom_target(ci_cmake_flags foreach(COMPILER g++-4.8 g++-4.9 g++-5 g++-6 g++-7 g++-8 g++-9 g++-10 clang++-3.5 clang++-3.6 clang++-3.7 clang++-3.8 clang++-3.9 clang++-4.0 clang++-5.0 clang++-6.0 clang++-7 clang++-8 clang++-9 clang++-10 clang++-11 clang++-12 clang++-13) find_program(COMPILER_TOOL NAMES ${COMPILER}) if (COMPILER_TOOL) + # fix for https://github.com/nlohmann/json/pull/3101#issuecomment-998788786 / https://stackoverflow.com/a/64051725/266378 + if ("${COMPILER}" STREQUAL "clang++-9") + set(ADDITIONAL_FLAGS "-DCMAKE_CXX_FLAGS=--gcc-toolchain=/root/gcc/9") + endif() + add_custom_target(ci_test_compiler_${COMPILER} COMMAND CXX=${COMPILER} ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Debug -GNinja -DJSON_BuildTests=ON -DJSON_FastTests=ON -S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_compiler_${COMPILER} + ${ADDITIONAL_FLAGS} COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_compiler_${COMPILER} COMMAND cd ${PROJECT_BINARY_DIR}/build_compiler_${COMPILER} && ${CMAKE_CTEST_COMMAND} --parallel ${N} --exclude-regex "test-unicode" --output-on-failure COMMENT "Compile and test with ${COMPILER}" From 30ab9c402c1a4187d261e5f385f4c81d2f630357 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Fri, 24 Dec 2021 09:27:18 +0100 Subject: [PATCH 21/38] :rotating_light: fix warnings --- .../nlohmann/detail/input/binary_reader.hpp | 20 +++---- include/nlohmann/detail/input/json_sax.hpp | 12 ++-- include/nlohmann/detail/input/lexer.hpp | 6 +- include/nlohmann/detail/input/parser.hpp | 4 +- .../nlohmann/detail/output/binary_writer.hpp | 4 +- include/nlohmann/json.hpp | 12 ++-- single_include/nlohmann/json.hpp | 58 +++++++++---------- 7 files changed, 58 insertions(+), 58 deletions(-) diff --git a/include/nlohmann/detail/input/binary_reader.hpp b/include/nlohmann/detail/input/binary_reader.hpp index 3add2c1150..7922e0838f 100644 --- a/include/nlohmann/detail/input/binary_reader.hpp +++ b/include/nlohmann/detail/input/binary_reader.hpp @@ -161,7 +161,7 @@ class binary_reader std::int32_t document_size{}; get_number(input_format_t::bson, document_size); - if (JSON_HEDLEY_UNLIKELY(!sax->start_object(std::size_t(-1)))) + if (JSON_HEDLEY_UNLIKELY(!sax->start_object(static_cast(-1)))) { return false; } @@ -379,7 +379,7 @@ class binary_reader std::int32_t document_size{}; get_number(input_format_t::bson, document_size); - if (JSON_HEDLEY_UNLIKELY(!sax->start_array(std::size_t(-1)))) + if (JSON_HEDLEY_UNLIKELY(!sax->start_array(static_cast(-1)))) { return false; } @@ -638,7 +638,7 @@ class binary_reader } case 0x9F: // array (indefinite length) - return get_cbor_array(std::size_t(-1), tag_handler); + return get_cbor_array(static_cast(-1), tag_handler); // map (0x00..0x17 pairs of data items follow) case 0xA0: @@ -692,7 +692,7 @@ class binary_reader } case 0xBF: // map (indefinite length) - return get_cbor_object(std::size_t(-1), tag_handler); + return get_cbor_object(static_cast(-1), tag_handler); case 0xC6: // tagged item case 0xC7: @@ -1076,7 +1076,7 @@ class binary_reader } /*! - @param[in] len the length of the array or std::size_t(-1) for an + @param[in] len the length of the array or static_cast(-1) for an array of indefinite size @param[in] tag_handler how CBOR tags should be treated @return whether array creation completed @@ -1089,7 +1089,7 @@ class binary_reader return false; } - if (len != std::size_t(-1)) + if (len != static_cast(-1)) { for (std::size_t i = 0; i < len; ++i) { @@ -1114,7 +1114,7 @@ class binary_reader } /*! - @param[in] len the length of the object or std::size_t(-1) for an + @param[in] len the length of the object or static_cast(-1) for an object of indefinite size @param[in] tag_handler how CBOR tags should be treated @return whether object creation completed @@ -1130,7 +1130,7 @@ class binary_reader if (len != 0) { string_t key; - if (len != std::size_t(-1)) + if (len != static_cast(-1)) { for (std::size_t i = 0; i < len; ++i) { @@ -2140,7 +2140,7 @@ class binary_reader } else { - if (JSON_HEDLEY_UNLIKELY(!sax->start_array(std::size_t(-1)))) + if (JSON_HEDLEY_UNLIKELY(!sax->start_array(static_cast(-1)))) { return false; } @@ -2210,7 +2210,7 @@ class binary_reader } else { - if (JSON_HEDLEY_UNLIKELY(!sax->start_object(std::size_t(-1)))) + if (JSON_HEDLEY_UNLIKELY(!sax->start_object(static_cast(-1)))) { return false; } diff --git a/include/nlohmann/detail/input/json_sax.hpp b/include/nlohmann/detail/input/json_sax.hpp index 67278f8566..250f113dda 100644 --- a/include/nlohmann/detail/input/json_sax.hpp +++ b/include/nlohmann/detail/input/json_sax.hpp @@ -222,7 +222,7 @@ class json_sax_dom_parser { ref_stack.push_back(handle_value(BasicJsonType::value_t::object)); - if (JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) && len > ref_stack.back()->max_size())) + if (JSON_HEDLEY_UNLIKELY(len != static_cast(-1) && len > ref_stack.back()->max_size())) { JSON_THROW(out_of_range::create(408, "excessive object size: " + std::to_string(len), *ref_stack.back())); } @@ -248,7 +248,7 @@ class json_sax_dom_parser { ref_stack.push_back(handle_value(BasicJsonType::value_t::array)); - if (JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) && len > ref_stack.back()->max_size())) + if (JSON_HEDLEY_UNLIKELY(len != static_cast(-1) && len > ref_stack.back()->max_size())) { JSON_THROW(out_of_range::create(408, "excessive array size: " + std::to_string(len), *ref_stack.back())); } @@ -403,7 +403,7 @@ class json_sax_dom_callback_parser ref_stack.push_back(val.second); // check object limit - if (ref_stack.back() && JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) && len > ref_stack.back()->max_size())) + if (ref_stack.back() && JSON_HEDLEY_UNLIKELY(len != static_cast(-1) && len > ref_stack.back()->max_size())) { JSON_THROW(out_of_range::create(408, "excessive object size: " + std::to_string(len), *ref_stack.back())); } @@ -473,7 +473,7 @@ class json_sax_dom_callback_parser ref_stack.push_back(val.second); // check array limit - if (ref_stack.back() && JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) && len > ref_stack.back()->max_size())) + if (ref_stack.back() && JSON_HEDLEY_UNLIKELY(len != static_cast(-1) && len > ref_stack.back()->max_size())) { JSON_THROW(out_of_range::create(408, "excessive array size: " + std::to_string(len), *ref_stack.back())); } @@ -676,7 +676,7 @@ class json_sax_acceptor return true; } - bool start_object(std::size_t /*unused*/ = std::size_t(-1)) + bool start_object(std::size_t /*unused*/ = static_cast(-1)) { return true; } @@ -691,7 +691,7 @@ class json_sax_acceptor return true; } - bool start_array(std::size_t /*unused*/ = std::size_t(-1)) + bool start_array(std::size_t /*unused*/ = static_cast(-1)) { return true; } diff --git a/include/nlohmann/detail/input/lexer.hpp b/include/nlohmann/detail/input/lexer.hpp index 3a47167e9c..45b0954033 100644 --- a/include/nlohmann/detail/input/lexer.hpp +++ b/include/nlohmann/detail/input/lexer.hpp @@ -1541,17 +1541,17 @@ class lexer : public lexer_base // literals case 't': { - std::array true_literal = {{char_type('t'), char_type('r'), char_type('u'), char_type('e')}}; + std::array true_literal = {{static_cast('t'), static_cast('r'), static_cast('u'), static_cast('e')}}; return scan_literal(true_literal.data(), true_literal.size(), token_type::literal_true); } case 'f': { - std::array false_literal = {{char_type('f'), char_type('a'), char_type('l'), char_type('s'), char_type('e')}}; + std::array false_literal = {{static_cast('f'), static_cast('a'), static_cast('l'), static_cast('s'), static_cast('e')}}; return scan_literal(false_literal.data(), false_literal.size(), token_type::literal_false); } case 'n': { - std::array null_literal = {{char_type('n'), char_type('u'), char_type('l'), char_type('l')}}; + std::array null_literal = {{static_cast('n'), static_cast('u'), static_cast('l'), static_cast('l')}}; return scan_literal(null_literal.data(), null_literal.size(), token_type::literal_null); } diff --git a/include/nlohmann/detail/input/parser.hpp b/include/nlohmann/detail/input/parser.hpp index 99cdd05ecb..024dd040f7 100644 --- a/include/nlohmann/detail/input/parser.hpp +++ b/include/nlohmann/detail/input/parser.hpp @@ -186,7 +186,7 @@ class parser { case token_type::begin_object: { - if (JSON_HEDLEY_UNLIKELY(!sax->start_object(std::size_t(-1)))) + if (JSON_HEDLEY_UNLIKELY(!sax->start_object(static_cast(-1)))) { return false; } @@ -231,7 +231,7 @@ class parser case token_type::begin_array: { - if (JSON_HEDLEY_UNLIKELY(!sax->start_array(std::size_t(-1)))) + if (JSON_HEDLEY_UNLIKELY(!sax->start_array(static_cast(-1)))) { return false; } diff --git a/include/nlohmann/detail/output/binary_writer.hpp b/include/nlohmann/detail/output/binary_writer.hpp index 23b9ff16e0..d536434fbd 100644 --- a/include/nlohmann/detail/output/binary_writer.hpp +++ b/include/nlohmann/detail/output/binary_writer.hpp @@ -1083,7 +1083,7 @@ class binary_writer { std::size_t array_index = 0ul; - const std::size_t embedded_document_size = std::accumulate(std::begin(value), std::end(value), std::size_t(0), [&array_index](std::size_t result, const typename BasicJsonType::array_t::value_type & el) + const std::size_t embedded_document_size = std::accumulate(std::begin(value), std::end(value), static_cast(0), [&array_index](std::size_t result, const typename BasicJsonType::array_t::value_type & el) { return result + calc_bson_element_size(std::to_string(array_index++), el); }); @@ -1233,7 +1233,7 @@ class binary_writer */ static std::size_t calc_bson_object_size(const typename BasicJsonType::object_t& value) { - std::size_t document_size = std::accumulate(value.begin(), value.end(), std::size_t(0), + std::size_t document_size = std::accumulate(value.begin(), value.end(), static_cast(0), [](size_t result, const typename BasicJsonType::object_t::value_type & el) { return result += calc_bson_element_size(el.first, el.second); diff --git a/include/nlohmann/json.hpp b/include/nlohmann/json.hpp index 16c9353ca1..1af58d1d62 100644 --- a/include/nlohmann/json.hpp +++ b/include/nlohmann/json.hpp @@ -1031,25 +1031,25 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec case value_t::boolean: { - boolean = boolean_t(false); + boolean = static_cast(false); break; } case value_t::number_integer: { - number_integer = number_integer_t(0); + number_integer = static_cast(0); break; } case value_t::number_unsigned: { - number_unsigned = number_unsigned_t(0); + number_unsigned = static_cast(0); break; } case value_t::number_float: { - number_float = number_float_t(0.0); + number_float = static_cast(0.0); break; } @@ -1291,10 +1291,10 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec return it; } - reference set_parent(reference j, std::size_t old_capacity = std::size_t(-1)) + reference set_parent(reference j, std::size_t old_capacity = static_cast(-1)) { #if JSON_DIAGNOSTICS - if (old_capacity != std::size_t(-1)) + if (old_capacity != static_cast(-1)) { // see https://github.com/nlohmann/json/issues/2838 JSON_ASSERT(type() == value_t::array); diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 4342d24bfa..2d3025e3f9 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -6214,7 +6214,7 @@ class json_sax_dom_parser { ref_stack.push_back(handle_value(BasicJsonType::value_t::object)); - if (JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) && len > ref_stack.back()->max_size())) + if (JSON_HEDLEY_UNLIKELY(len != static_cast(-1) && len > ref_stack.back()->max_size())) { JSON_THROW(out_of_range::create(408, "excessive object size: " + std::to_string(len), *ref_stack.back())); } @@ -6240,7 +6240,7 @@ class json_sax_dom_parser { ref_stack.push_back(handle_value(BasicJsonType::value_t::array)); - if (JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) && len > ref_stack.back()->max_size())) + if (JSON_HEDLEY_UNLIKELY(len != static_cast(-1) && len > ref_stack.back()->max_size())) { JSON_THROW(out_of_range::create(408, "excessive array size: " + std::to_string(len), *ref_stack.back())); } @@ -6395,7 +6395,7 @@ class json_sax_dom_callback_parser ref_stack.push_back(val.second); // check object limit - if (ref_stack.back() && JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) && len > ref_stack.back()->max_size())) + if (ref_stack.back() && JSON_HEDLEY_UNLIKELY(len != static_cast(-1) && len > ref_stack.back()->max_size())) { JSON_THROW(out_of_range::create(408, "excessive object size: " + std::to_string(len), *ref_stack.back())); } @@ -6465,7 +6465,7 @@ class json_sax_dom_callback_parser ref_stack.push_back(val.second); // check array limit - if (ref_stack.back() && JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) && len > ref_stack.back()->max_size())) + if (ref_stack.back() && JSON_HEDLEY_UNLIKELY(len != static_cast(-1) && len > ref_stack.back()->max_size())) { JSON_THROW(out_of_range::create(408, "excessive array size: " + std::to_string(len), *ref_stack.back())); } @@ -6668,7 +6668,7 @@ class json_sax_acceptor return true; } - bool start_object(std::size_t /*unused*/ = std::size_t(-1)) + bool start_object(std::size_t /*unused*/ = static_cast(-1)) { return true; } @@ -6683,7 +6683,7 @@ class json_sax_acceptor return true; } - bool start_array(std::size_t /*unused*/ = std::size_t(-1)) + bool start_array(std::size_t /*unused*/ = static_cast(-1)) { return true; } @@ -8249,17 +8249,17 @@ class lexer : public lexer_base // literals case 't': { - std::array true_literal = {{char_type('t'), char_type('r'), char_type('u'), char_type('e')}}; + std::array true_literal = {{static_cast('t'), static_cast('r'), static_cast('u'), static_cast('e')}}; return scan_literal(true_literal.data(), true_literal.size(), token_type::literal_true); } case 'f': { - std::array false_literal = {{char_type('f'), char_type('a'), char_type('l'), char_type('s'), char_type('e')}}; + std::array false_literal = {{static_cast('f'), static_cast('a'), static_cast('l'), static_cast('s'), static_cast('e')}}; return scan_literal(false_literal.data(), false_literal.size(), token_type::literal_false); } case 'n': { - std::array null_literal = {{char_type('n'), char_type('u'), char_type('l'), char_type('l')}}; + std::array null_literal = {{static_cast('n'), static_cast('u'), static_cast('l'), static_cast('l')}}; return scan_literal(null_literal.data(), null_literal.size(), token_type::literal_null); } @@ -8629,7 +8629,7 @@ class binary_reader std::int32_t document_size{}; get_number(input_format_t::bson, document_size); - if (JSON_HEDLEY_UNLIKELY(!sax->start_object(std::size_t(-1)))) + if (JSON_HEDLEY_UNLIKELY(!sax->start_object(static_cast(-1)))) { return false; } @@ -8847,7 +8847,7 @@ class binary_reader std::int32_t document_size{}; get_number(input_format_t::bson, document_size); - if (JSON_HEDLEY_UNLIKELY(!sax->start_array(std::size_t(-1)))) + if (JSON_HEDLEY_UNLIKELY(!sax->start_array(static_cast(-1)))) { return false; } @@ -9106,7 +9106,7 @@ class binary_reader } case 0x9F: // array (indefinite length) - return get_cbor_array(std::size_t(-1), tag_handler); + return get_cbor_array(static_cast(-1), tag_handler); // map (0x00..0x17 pairs of data items follow) case 0xA0: @@ -9160,7 +9160,7 @@ class binary_reader } case 0xBF: // map (indefinite length) - return get_cbor_object(std::size_t(-1), tag_handler); + return get_cbor_object(static_cast(-1), tag_handler); case 0xC6: // tagged item case 0xC7: @@ -9544,7 +9544,7 @@ class binary_reader } /*! - @param[in] len the length of the array or std::size_t(-1) for an + @param[in] len the length of the array or static_cast(-1) for an array of indefinite size @param[in] tag_handler how CBOR tags should be treated @return whether array creation completed @@ -9557,7 +9557,7 @@ class binary_reader return false; } - if (len != std::size_t(-1)) + if (len != static_cast(-1)) { for (std::size_t i = 0; i < len; ++i) { @@ -9582,7 +9582,7 @@ class binary_reader } /*! - @param[in] len the length of the object or std::size_t(-1) for an + @param[in] len the length of the object or static_cast(-1) for an object of indefinite size @param[in] tag_handler how CBOR tags should be treated @return whether object creation completed @@ -9598,7 +9598,7 @@ class binary_reader if (len != 0) { string_t key; - if (len != std::size_t(-1)) + if (len != static_cast(-1)) { for (std::size_t i = 0; i < len; ++i) { @@ -10608,7 +10608,7 @@ class binary_reader } else { - if (JSON_HEDLEY_UNLIKELY(!sax->start_array(std::size_t(-1)))) + if (JSON_HEDLEY_UNLIKELY(!sax->start_array(static_cast(-1)))) { return false; } @@ -10678,7 +10678,7 @@ class binary_reader } else { - if (JSON_HEDLEY_UNLIKELY(!sax->start_object(std::size_t(-1)))) + if (JSON_HEDLEY_UNLIKELY(!sax->start_object(static_cast(-1)))) { return false; } @@ -11191,7 +11191,7 @@ class parser { case token_type::begin_object: { - if (JSON_HEDLEY_UNLIKELY(!sax->start_object(std::size_t(-1)))) + if (JSON_HEDLEY_UNLIKELY(!sax->start_object(static_cast(-1)))) { return false; } @@ -11236,7 +11236,7 @@ class parser case token_type::begin_array: { - if (JSON_HEDLEY_UNLIKELY(!sax->start_array(std::size_t(-1)))) + if (JSON_HEDLEY_UNLIKELY(!sax->start_array(static_cast(-1)))) { return false; } @@ -14830,7 +14830,7 @@ class binary_writer { std::size_t array_index = 0ul; - const std::size_t embedded_document_size = std::accumulate(std::begin(value), std::end(value), std::size_t(0), [&array_index](std::size_t result, const typename BasicJsonType::array_t::value_type & el) + const std::size_t embedded_document_size = std::accumulate(std::begin(value), std::end(value), static_cast(0), [&array_index](std::size_t result, const typename BasicJsonType::array_t::value_type & el) { return result + calc_bson_element_size(std::to_string(array_index++), el); }); @@ -14980,7 +14980,7 @@ class binary_writer */ static std::size_t calc_bson_object_size(const typename BasicJsonType::object_t& value) { - std::size_t document_size = std::accumulate(value.begin(), value.end(), std::size_t(0), + std::size_t document_size = std::accumulate(value.begin(), value.end(), static_cast(0), [](size_t result, const typename BasicJsonType::object_t::value_type & el) { return result += calc_bson_element_size(el.first, el.second); @@ -18651,25 +18651,25 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec case value_t::boolean: { - boolean = boolean_t(false); + boolean = static_cast(false); break; } case value_t::number_integer: { - number_integer = number_integer_t(0); + number_integer = static_cast(0); break; } case value_t::number_unsigned: { - number_unsigned = number_unsigned_t(0); + number_unsigned = static_cast(0); break; } case value_t::number_float: { - number_float = number_float_t(0.0); + number_float = static_cast(0.0); break; } @@ -18911,10 +18911,10 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec return it; } - reference set_parent(reference j, std::size_t old_capacity = std::size_t(-1)) + reference set_parent(reference j, std::size_t old_capacity = static_cast(-1)) { #if JSON_DIAGNOSTICS - if (old_capacity != std::size_t(-1)) + if (old_capacity != static_cast(-1)) { // see https://github.com/nlohmann/json/issues/2838 JSON_ASSERT(type() == value_t::array); From 1ca951042772e128d56157a36beb5952e2d560e1 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Fri, 24 Dec 2021 09:41:27 +0100 Subject: [PATCH 22/38] :rotating_light: fix warnings --- .../nlohmann/byte_container_with_subtype.hpp | 2 +- .../nlohmann/detail/input/binary_reader.hpp | 4 ++-- include/nlohmann/detail/input/lexer.hpp | 2 +- include/nlohmann/detail/output/serializer.hpp | 10 +++++----- single_include/nlohmann/json.hpp | 18 +++++++++--------- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/include/nlohmann/byte_container_with_subtype.hpp b/include/nlohmann/byte_container_with_subtype.hpp index 4086e0834d..474508f317 100644 --- a/include/nlohmann/byte_container_with_subtype.hpp +++ b/include/nlohmann/byte_container_with_subtype.hpp @@ -112,7 +112,7 @@ class byte_container_with_subtype : public BinaryType */ constexpr subtype_type subtype() const noexcept { - return m_has_subtype ? m_subtype : subtype_type(-1); + return m_has_subtype ? m_subtype : static_cast(-1); } /*! diff --git a/include/nlohmann/detail/input/binary_reader.hpp b/include/nlohmann/detail/input/binary_reader.hpp index 7922e0838f..65e0047ac7 100644 --- a/include/nlohmann/detail/input/binary_reader.hpp +++ b/include/nlohmann/detail/input/binary_reader.hpp @@ -318,7 +318,7 @@ class binary_reader default: // anything else not supported (yet) { std::array cr{{}}; - (std::snprintf)(cr.data(), cr.size(), "%.2hhX", static_cast(element_type)); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg) + static_cast((std::snprintf)(cr.data(), cr.size(), "%.2hhX", static_cast(element_type))); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg) return sax->parse_error(element_type_parse_position, std::string(cr.data()), parse_error::create(114, element_type_parse_position, "Unsupported BSON record type 0x" + std::string(cr.data()), BasicJsonType())); } } @@ -2462,7 +2462,7 @@ class binary_reader std::string get_token_string() const { std::array cr{{}}; - (std::snprintf)(cr.data(), cr.size(), "%.2hhX", static_cast(current)); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg) + static_cast((std::snprintf)(cr.data(), cr.size(), "%.2hhX", static_cast(current))); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg) return std::string{cr.data()}; } diff --git a/include/nlohmann/detail/input/lexer.hpp b/include/nlohmann/detail/input/lexer.hpp index 45b0954033..adaf01e387 100644 --- a/include/nlohmann/detail/input/lexer.hpp +++ b/include/nlohmann/detail/input/lexer.hpp @@ -1447,7 +1447,7 @@ class lexer : public lexer_base { // escape control characters std::array cs{{}}; - (std::snprintf)(cs.data(), cs.size(), "", static_cast(c)); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg) + static_cast((std::snprintf)(cs.data(), cs.size(), "", static_cast(c))); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg) result += cs.data(); } else diff --git a/include/nlohmann/detail/output/serializer.hpp b/include/nlohmann/detail/output/serializer.hpp index 07fa3e9682..0b49c5bca4 100644 --- a/include/nlohmann/detail/output/serializer.hpp +++ b/include/nlohmann/detail/output/serializer.hpp @@ -457,16 +457,16 @@ class serializer if (codepoint <= 0xFFFF) { // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg,hicpp-vararg) - (std::snprintf)(string_buffer.data() + bytes, 7, "\\u%04x", - static_cast(codepoint)); + static_cast((std::snprintf)(string_buffer.data() + bytes, 7, "\\u%04x", + static_cast(codepoint))); bytes += 6; } else { // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg,hicpp-vararg) - (std::snprintf)(string_buffer.data() + bytes, 13, "\\u%04x\\u%04x", - static_cast(0xD7C0u + (codepoint >> 10u)), - static_cast(0xDC00u + (codepoint & 0x3FFu))); + static_cast((std::snprintf)(string_buffer.data() + bytes, 13, "\\u%04x\\u%04x", + static_cast(0xD7C0u + (codepoint >> 10u)), + static_cast(0xDC00u + (codepoint & 0x3FFu)))); bytes += 12; } } diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 2d3025e3f9..b9c4895f0f 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -5294,7 +5294,7 @@ class byte_container_with_subtype : public BinaryType */ constexpr subtype_type subtype() const noexcept { - return m_has_subtype ? m_subtype : subtype_type(-1); + return m_has_subtype ? m_subtype : static_cast(-1); } /*! @@ -8155,7 +8155,7 @@ class lexer : public lexer_base { // escape control characters std::array cs{{}}; - (std::snprintf)(cs.data(), cs.size(), "", static_cast(c)); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg) + static_cast((std::snprintf)(cs.data(), cs.size(), "", static_cast(c))); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg) result += cs.data(); } else @@ -8786,7 +8786,7 @@ class binary_reader default: // anything else not supported (yet) { std::array cr{{}}; - (std::snprintf)(cr.data(), cr.size(), "%.2hhX", static_cast(element_type)); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg) + static_cast((std::snprintf)(cr.data(), cr.size(), "%.2hhX", static_cast(element_type))); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg) return sax->parse_error(element_type_parse_position, std::string(cr.data()), parse_error::create(114, element_type_parse_position, "Unsupported BSON record type 0x" + std::string(cr.data()), BasicJsonType())); } } @@ -10930,7 +10930,7 @@ class binary_reader std::string get_token_string() const { std::array cr{{}}; - (std::snprintf)(cr.data(), cr.size(), "%.2hhX", static_cast(current)); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg) + static_cast((std::snprintf)(cr.data(), cr.size(), "%.2hhX", static_cast(current))); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg) return std::string{cr.data()}; } @@ -16961,16 +16961,16 @@ class serializer if (codepoint <= 0xFFFF) { // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg,hicpp-vararg) - (std::snprintf)(string_buffer.data() + bytes, 7, "\\u%04x", - static_cast(codepoint)); + static_cast((std::snprintf)(string_buffer.data() + bytes, 7, "\\u%04x", + static_cast(codepoint))); bytes += 6; } else { // NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg,hicpp-vararg) - (std::snprintf)(string_buffer.data() + bytes, 13, "\\u%04x\\u%04x", - static_cast(0xD7C0u + (codepoint >> 10u)), - static_cast(0xDC00u + (codepoint & 0x3FFu))); + static_cast((std::snprintf)(string_buffer.data() + bytes, 13, "\\u%04x\\u%04x", + static_cast(0xD7C0u + (codepoint >> 10u)), + static_cast(0xDC00u + (codepoint & 0x3FFu)))); bytes += 12; } } From 742d85fc7ce3a3f271f8007d7afc3221ef5b5da8 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Fri, 24 Dec 2021 13:11:25 +0100 Subject: [PATCH 23/38] :rotating_light: fix warnings --- include/nlohmann/detail/output/binary_writer.hpp | 2 +- single_include/nlohmann/json.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/nlohmann/detail/output/binary_writer.hpp b/include/nlohmann/detail/output/binary_writer.hpp index d536434fbd..598587141f 100644 --- a/include/nlohmann/detail/output/binary_writer.hpp +++ b/include/nlohmann/detail/output/binary_writer.hpp @@ -1127,7 +1127,7 @@ class binary_writer write_bson_entry_header(name, 0x05); write_number(static_cast(value.size())); - write_number(value.has_subtype() ? static_cast(value.subtype()) : std::uint8_t(0x00)); + write_number(value.has_subtype() ? static_cast(value.subtype()) : static_cast(0x00)); oa->write_characters(reinterpret_cast(value.data()), value.size()); } diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index b9c4895f0f..e2239669fd 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -14874,7 +14874,7 @@ class binary_writer write_bson_entry_header(name, 0x05); write_number(static_cast(value.size())); - write_number(value.has_subtype() ? static_cast(value.subtype()) : std::uint8_t(0x00)); + write_number(value.has_subtype() ? static_cast(value.subtype()) : static_cast(0x00)); oa->write_characters(reinterpret_cast(value.data()), value.size()); } From 05874dcf70f8e35ddcaa77342f65ceb7b672c20d Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Fri, 24 Dec 2021 13:29:19 +0100 Subject: [PATCH 24/38] :rotating_light: fix warnings --- test/src/unit-class_parser.cpp | 4 ++-- test/src/unit-deserialization.cpp | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/test/src/unit-class_parser.cpp b/test/src/unit-class_parser.cpp index 22485048c1..3b54cac475 100644 --- a/test/src/unit-class_parser.cpp +++ b/test/src/unit-class_parser.cpp @@ -93,7 +93,7 @@ class SaxEventLogger bool start_object(std::size_t elements) { - if (elements == std::size_t(-1)) + if (elements == reinterpret_cast(-1)) { events.emplace_back("start_object()"); } @@ -118,7 +118,7 @@ class SaxEventLogger bool start_array(std::size_t elements) { - if (elements == std::size_t(-1)) + if (elements == reinterpret_cast(-1)) { events.emplace_back("start_array()"); } diff --git a/test/src/unit-deserialization.cpp b/test/src/unit-deserialization.cpp index 500966e9ee..05fb21e3a0 100644 --- a/test/src/unit-deserialization.cpp +++ b/test/src/unit-deserialization.cpp @@ -93,7 +93,7 @@ struct SaxEventLogger : public nlohmann::json_sax bool start_object(std::size_t elements) override { - if (elements == std::size_t(-1)) + if (elements == reinterpret_cast(-1)) { events.emplace_back("start_object()"); } @@ -118,7 +118,7 @@ struct SaxEventLogger : public nlohmann::json_sax bool start_array(std::size_t elements) override { - if (elements == std::size_t(-1)) + if (elements == reinterpret_cast(-1)) { events.emplace_back("start_array()"); } @@ -148,7 +148,7 @@ struct SaxEventLoggerExitAfterStartObject : public SaxEventLogger { bool start_object(std::size_t elements) override { - if (elements == std::size_t(-1)) + if (elements == reinterpret_cast(-1)) { events.emplace_back("start_object()"); } @@ -173,7 +173,7 @@ struct SaxEventLoggerExitAfterStartArray : public SaxEventLogger { bool start_array(std::size_t elements) override { - if (elements == std::size_t(-1)) + if (elements == reinterpret_cast(-1)) { events.emplace_back("start_array()"); } From 69f9c41d29defcfad4b98e5c415deb30df268484 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Fri, 24 Dec 2021 13:41:05 +0100 Subject: [PATCH 25/38] :rotating_light: fix warnings --- test/src/unit-class_parser.cpp | 4 ++-- test/src/unit-deserialization.cpp | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/test/src/unit-class_parser.cpp b/test/src/unit-class_parser.cpp index 3b54cac475..9b3b4a1457 100644 --- a/test/src/unit-class_parser.cpp +++ b/test/src/unit-class_parser.cpp @@ -93,7 +93,7 @@ class SaxEventLogger bool start_object(std::size_t elements) { - if (elements == reinterpret_cast(-1)) + if (elements == static_cast(-1)) { events.emplace_back("start_object()"); } @@ -118,7 +118,7 @@ class SaxEventLogger bool start_array(std::size_t elements) { - if (elements == reinterpret_cast(-1)) + if (elements == static_cast(-1)) { events.emplace_back("start_array()"); } diff --git a/test/src/unit-deserialization.cpp b/test/src/unit-deserialization.cpp index 05fb21e3a0..25bd8699b9 100644 --- a/test/src/unit-deserialization.cpp +++ b/test/src/unit-deserialization.cpp @@ -93,7 +93,7 @@ struct SaxEventLogger : public nlohmann::json_sax bool start_object(std::size_t elements) override { - if (elements == reinterpret_cast(-1)) + if (elements == static_cast(-1)) { events.emplace_back("start_object()"); } @@ -118,7 +118,7 @@ struct SaxEventLogger : public nlohmann::json_sax bool start_array(std::size_t elements) override { - if (elements == reinterpret_cast(-1)) + if (elements == static_cast(-1)) { events.emplace_back("start_array()"); } @@ -148,7 +148,7 @@ struct SaxEventLoggerExitAfterStartObject : public SaxEventLogger { bool start_object(std::size_t elements) override { - if (elements == reinterpret_cast(-1)) + if (elements == static_cast(-1)) { events.emplace_back("start_object()"); } @@ -173,7 +173,7 @@ struct SaxEventLoggerExitAfterStartArray : public SaxEventLogger { bool start_array(std::size_t elements) override { - if (elements == reinterpret_cast(-1)) + if (elements == static_cast(-1)) { events.emplace_back("start_array()"); } From 78baaa99757ca79bc4cf6000cf8eaacdbc5a7f3c Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Fri, 24 Dec 2021 13:52:14 +0100 Subject: [PATCH 26/38] :rotating_light: fix warnings --- test/src/unit-cbor.cpp | 2 +- test/src/unit-msgpack.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/src/unit-cbor.cpp b/test/src/unit-cbor.cpp index d67745e75a..95a2c8885d 100644 --- a/test/src/unit-cbor.cpp +++ b/test/src/unit-cbor.cpp @@ -610,7 +610,7 @@ TEST_CASE("CBOR") SECTION("-32768..-129 (int 16)") { - for (int16_t i = -32768; i <= int16_t(-129); ++i) + for (int16_t i = -32768; i <= static_cast(-129); ++i) { CAPTURE(i) diff --git a/test/src/unit-msgpack.cpp b/test/src/unit-msgpack.cpp index 0ac9e30c1d..e593c364c0 100644 --- a/test/src/unit-msgpack.cpp +++ b/test/src/unit-msgpack.cpp @@ -446,7 +446,7 @@ TEST_CASE("MessagePack") SECTION("-32768..-129 (int 16)") { - for (int16_t i = -32768; i <= int16_t(-129); ++i) + for (int16_t i = -32768; i <= static_cast(-129); ++i) { CAPTURE(i) From 4bf052a780c0b7b563be25844085fd269f72ca45 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Fri, 24 Dec 2021 14:19:17 +0100 Subject: [PATCH 27/38] :green_heart: fix script --- cmake/ci.cmake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cmake/ci.cmake b/cmake/ci.cmake index 98a91defb6..53f7acf065 100644 --- a/cmake/ci.cmake +++ b/cmake/ci.cmake @@ -817,6 +817,8 @@ foreach(COMPILER g++-4.8 g++-4.9 g++-5 g++-6 g++-7 g++-8 g++-9 g++-10 clang++-3. # fix for https://github.com/nlohmann/json/pull/3101#issuecomment-998788786 / https://stackoverflow.com/a/64051725/266378 if ("${COMPILER}" STREQUAL "clang++-9") set(ADDITIONAL_FLAGS "-DCMAKE_CXX_FLAGS=--gcc-toolchain=/root/gcc/9") + else() + unset(ADDITIONAL_FLAGS) endif() add_custom_target(ci_test_compiler_${COMPILER} From 6e6a82fd66c90b32a74163bce4d1f0c7602f8699 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Fri, 24 Dec 2021 14:36:40 +0100 Subject: [PATCH 28/38] :rotating_light: fix warnings --- test/src/unit-byte_container_with_subtype.cpp | 6 +++--- test/src/unit-hash.cpp | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/test/src/unit-byte_container_with_subtype.cpp b/test/src/unit-byte_container_with_subtype.cpp index 51ce9c0f4f..9ff8ee9e95 100644 --- a/test/src/unit-byte_container_with_subtype.cpp +++ b/test/src/unit-byte_container_with_subtype.cpp @@ -41,11 +41,11 @@ TEST_CASE("byte_container_with_subtype") nlohmann::byte_container_with_subtype> container; CHECK(!container.has_subtype()); - CHECK(container.subtype() == subtype_type(-1)); + CHECK(container.subtype() == static_cast(-1)); container.clear_subtype(); CHECK(!container.has_subtype()); - CHECK(container.subtype() == subtype_type(-1)); + CHECK(container.subtype() == static_cast(-1)); container.set_subtype(42); CHECK(container.has_subtype()); @@ -60,7 +60,7 @@ TEST_CASE("byte_container_with_subtype") container.clear_subtype(); CHECK(!container.has_subtype()); - CHECK(container.subtype() == subtype_type(-1)); + CHECK(container.subtype() == static_cast(-1)); } SECTION("comparisons") diff --git a/test/src/unit-hash.cpp b/test/src/unit-hash.cpp index 7abec52d19..dc0614ae07 100644 --- a/test/src/unit-hash.cpp +++ b/test/src/unit-hash.cpp @@ -56,7 +56,7 @@ TEST_CASE("hash") // number hashes.insert(std::hash {}(json(0))); - hashes.insert(std::hash {}(json(unsigned(0)))); + hashes.insert(std::hash {}(json(static_cast(0)))); hashes.insert(std::hash {}(json(-1))); hashes.insert(std::hash {}(json(0.0))); @@ -105,7 +105,7 @@ TEST_CASE("hash") // number hashes.insert(std::hash {}(ordered_json(0))); - hashes.insert(std::hash {}(ordered_json(unsigned(0)))); + hashes.insert(std::hash {}(ordered_json(static_cast(0)))); hashes.insert(std::hash {}(ordered_json(-1))); hashes.insert(std::hash {}(ordered_json(0.0))); From 7001266b52649f9036b0e4b44673402763842290 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Fri, 24 Dec 2021 14:59:42 +0100 Subject: [PATCH 29/38] :rotating_light: fix warnings --- test/src/unit-regression1.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/src/unit-regression1.cpp b/test/src/unit-regression1.cpp index 3971addca5..9839e088e2 100644 --- a/test/src/unit-regression1.cpp +++ b/test/src/unit-regression1.cpp @@ -170,7 +170,7 @@ TEST_CASE("regression tests 1") json::number_float_t f1{j1}; CHECK(std::isnan(f1)); - json j2 = json::number_float_t(NAN); + json j2 = static_cast(NAN); CHECK(j2.is_number_float()); json::number_float_t f2{j2}; CHECK(std::isnan(f2)); @@ -183,7 +183,7 @@ TEST_CASE("regression tests 1") json::number_float_t f1{j1}; CHECK(!std::isfinite(f1)); - json j2 = json::number_float_t(INFINITY); + json j2 = json::static_cast(INFINITY); CHECK(j2.is_number_float()); json::number_float_t f2{j2}; CHECK(!std::isfinite(f2)); @@ -567,17 +567,17 @@ TEST_CASE("regression tests 1") SECTION("issue #378 - locale-independent num-to-str") { - setlocale(LC_NUMERIC, "de_DE.UTF-8"); + static_cast(setlocale(LC_NUMERIC, "de_DE.UTF-8")); // verify that dumped correctly with '.' and no grouping const json j1 = 12345.67; CHECK(json(12345.67).dump() == "12345.67"); - setlocale(LC_NUMERIC, "C"); + static_cast(setlocale(LC_NUMERIC, "C")); } SECTION("issue #379 - locale-independent str-to-num") { - setlocale(LC_NUMERIC, "de_DE.UTF-8"); + static_cast(setlocale(LC_NUMERIC, "de_DE.UTF-8")); // verify that parsed correctly despite using strtod internally CHECK(json::parse("3.14").get() == 3.14); @@ -910,7 +910,7 @@ TEST_CASE("regression tests 1") ++i; } - std::remove("test.json"); + static_cast(std::remove("test.json")); } } From 8372e03e57f38c40140ad5c2116009bdfc4461fc Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Fri, 24 Dec 2021 15:11:25 +0100 Subject: [PATCH 30/38] :rotating_light: fix warnings --- test/src/unit-regression1.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/src/unit-regression1.cpp b/test/src/unit-regression1.cpp index 9839e088e2..e91bbda144 100644 --- a/test/src/unit-regression1.cpp +++ b/test/src/unit-regression1.cpp @@ -183,7 +183,7 @@ TEST_CASE("regression tests 1") json::number_float_t f1{j1}; CHECK(!std::isfinite(f1)); - json j2 = json::static_cast(INFINITY); + json j2 = static_cast(INFINITY); CHECK(j2.is_number_float()); json::number_float_t f2{j2}; CHECK(!std::isfinite(f2)); From c4aeceaeca744e503dfbd638018f26bd0dbc112c Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Tue, 28 Dec 2021 09:01:04 +0100 Subject: [PATCH 31/38] :alembic: use fix from https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90050 --- cmake/ci.cmake | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cmake/ci.cmake b/cmake/ci.cmake index 53f7acf065..4162c8930e 100644 --- a/cmake/ci.cmake +++ b/cmake/ci.cmake @@ -814,9 +814,12 @@ add_custom_target(ci_cmake_flags foreach(COMPILER g++-4.8 g++-4.9 g++-5 g++-6 g++-7 g++-8 g++-9 g++-10 clang++-3.5 clang++-3.6 clang++-3.7 clang++-3.8 clang++-3.9 clang++-4.0 clang++-5.0 clang++-6.0 clang++-7 clang++-8 clang++-9 clang++-10 clang++-11 clang++-12 clang++-13) find_program(COMPILER_TOOL NAMES ${COMPILER}) if (COMPILER_TOOL) - # fix for https://github.com/nlohmann/json/pull/3101#issuecomment-998788786 / https://stackoverflow.com/a/64051725/266378 if ("${COMPILER}" STREQUAL "clang++-9") + # fix for https://github.com/nlohmann/json/pull/3101#issuecomment-998788786 / https://stackoverflow.com/a/64051725/266378 set(ADDITIONAL_FLAGS "-DCMAKE_CXX_FLAGS=--gcc-toolchain=/root/gcc/9") + elseif ("${COMPILER}" STREQUAL "g++-8") + # fix for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90050 + set(ADDITIONAL_FLAGS "-DCMAKE_CXX_FLAGS=-lstdc++fs") else() unset(ADDITIONAL_FLAGS) endif() From 0c27b7c58b289e9958e5d5c5577e511131cbf982 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Tue, 28 Dec 2021 13:36:20 +0100 Subject: [PATCH 32/38] :alembic: use fix from https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90050 --- cmake/ci.cmake | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cmake/ci.cmake b/cmake/ci.cmake index 4162c8930e..77d6509014 100644 --- a/cmake/ci.cmake +++ b/cmake/ci.cmake @@ -817,9 +817,6 @@ foreach(COMPILER g++-4.8 g++-4.9 g++-5 g++-6 g++-7 g++-8 g++-9 g++-10 clang++-3. if ("${COMPILER}" STREQUAL "clang++-9") # fix for https://github.com/nlohmann/json/pull/3101#issuecomment-998788786 / https://stackoverflow.com/a/64051725/266378 set(ADDITIONAL_FLAGS "-DCMAKE_CXX_FLAGS=--gcc-toolchain=/root/gcc/9") - elseif ("${COMPILER}" STREQUAL "g++-8") - # fix for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90050 - set(ADDITIONAL_FLAGS "-DCMAKE_CXX_FLAGS=-lstdc++fs") else() unset(ADDITIONAL_FLAGS) endif() @@ -834,6 +831,11 @@ foreach(COMPILER g++-4.8 g++-4.9 g++-5 g++-6 g++-7 g++-8 g++-9 g++-10 clang++-3. COMMAND cd ${PROJECT_BINARY_DIR}/build_compiler_${COMPILER} && ${CMAKE_CTEST_COMMAND} --parallel ${N} --exclude-regex "test-unicode" --output-on-failure COMMENT "Compile and test with ${COMPILER}" ) + + if ("${COMPILER}" STREQUAL "g++-8") + # fix for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90050 + target_link_libraries(ci_test_compiler_${COMPILER} PUBLIC stdc++fs) + endif() endif() unset(COMPILER_TOOL CACHE) endforeach() From 5e12e56eaeec8e9e5904a92b00b33efc7b339054 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Tue, 28 Dec 2021 13:53:03 +0100 Subject: [PATCH 33/38] :alembic: use fix from https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90050 --- cmake/ci.cmake | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cmake/ci.cmake b/cmake/ci.cmake index 77d6509014..4cdf186e3b 100644 --- a/cmake/ci.cmake +++ b/cmake/ci.cmake @@ -817,6 +817,9 @@ foreach(COMPILER g++-4.8 g++-4.9 g++-5 g++-6 g++-7 g++-8 g++-9 g++-10 clang++-3. if ("${COMPILER}" STREQUAL "clang++-9") # fix for https://github.com/nlohmann/json/pull/3101#issuecomment-998788786 / https://stackoverflow.com/a/64051725/266378 set(ADDITIONAL_FLAGS "-DCMAKE_CXX_FLAGS=--gcc-toolchain=/root/gcc/9") + elseif ("${COMPILER}" STREQUAL "g++-8") + # fix for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90050 + set(ADDITIONAL_FLAGS "-DCMAKE_EXE_LINKER_FLAGS=-lstdc++fs") else() unset(ADDITIONAL_FLAGS) endif() @@ -832,10 +835,7 @@ foreach(COMPILER g++-4.8 g++-4.9 g++-5 g++-6 g++-7 g++-8 g++-9 g++-10 clang++-3. COMMENT "Compile and test with ${COMPILER}" ) - if ("${COMPILER}" STREQUAL "g++-8") - # fix for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90050 - target_link_libraries(ci_test_compiler_${COMPILER} PUBLIC stdc++fs) - endif() + target_link_libraries(ci_test_compiler_${COMPILER} PUBLIC -lstdc++fs) endif() unset(COMPILER_TOOL CACHE) endforeach() From d5a95e4f92abadf60c10cd291c6edc145da1deaa Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Tue, 28 Dec 2021 14:32:01 +0100 Subject: [PATCH 34/38] :alembic: use fix from https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90050 --- cmake/ci.cmake | 3 --- test/CMakeLists.txt | 5 +++++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/cmake/ci.cmake b/cmake/ci.cmake index 4cdf186e3b..3d1149d62a 100644 --- a/cmake/ci.cmake +++ b/cmake/ci.cmake @@ -817,9 +817,6 @@ foreach(COMPILER g++-4.8 g++-4.9 g++-5 g++-6 g++-7 g++-8 g++-9 g++-10 clang++-3. if ("${COMPILER}" STREQUAL "clang++-9") # fix for https://github.com/nlohmann/json/pull/3101#issuecomment-998788786 / https://stackoverflow.com/a/64051725/266378 set(ADDITIONAL_FLAGS "-DCMAKE_CXX_FLAGS=--gcc-toolchain=/root/gcc/9") - elseif ("${COMPILER}" STREQUAL "g++-8") - # fix for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90050 - set(ADDITIONAL_FLAGS "-DCMAKE_EXE_LINKER_FLAGS=-lstdc++fs") else() unset(ADDITIONAL_FLAGS) endif() diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index ab598878ba..86af685f86 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -99,6 +99,11 @@ foreach(file ${files}) target_link_libraries(${testcase}_cpp17 PRIVATE ${NLOHMANN_JSON_TARGET_NAME}) target_compile_features(${testcase}_cpp17 PRIVATE cxx_std_17) + if (CMAKE_COMPILER_IS_GNUCC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0 AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0) + # fix for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90050 + target_link_libraries(${testcase}_cpp17 PRIVATE stdc++fs) + endif() + if (JSON_FastTests) add_test(NAME "${testcase}_cpp17" COMMAND ${testcase}_cpp17 ${DOCTEST_TEST_FILTER} From bd3270a1fe4e5328c12f6d8fcd532298e23d3c19 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Tue, 28 Dec 2021 14:37:30 +0100 Subject: [PATCH 35/38] :alembic: use fix from https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90050 --- cmake/ci.cmake | 2 -- 1 file changed, 2 deletions(-) diff --git a/cmake/ci.cmake b/cmake/ci.cmake index 3d1149d62a..acb797c5b7 100644 --- a/cmake/ci.cmake +++ b/cmake/ci.cmake @@ -831,8 +831,6 @@ foreach(COMPILER g++-4.8 g++-4.9 g++-5 g++-6 g++-7 g++-8 g++-9 g++-10 clang++-3. COMMAND cd ${PROJECT_BINARY_DIR}/build_compiler_${COMPILER} && ${CMAKE_CTEST_COMMAND} --parallel ${N} --exclude-regex "test-unicode" --output-on-failure COMMENT "Compile and test with ${COMPILER}" ) - - target_link_libraries(ci_test_compiler_${COMPILER} PUBLIC -lstdc++fs) endif() unset(COMPILER_TOOL CACHE) endforeach() From 41a3b339e9e56bd41bc6d9c07617baee6247f9f1 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Tue, 28 Dec 2021 15:03:23 +0100 Subject: [PATCH 36/38] :alembic: use fix from https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90050 --- test/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 86af685f86..1be50994d0 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -99,7 +99,7 @@ foreach(file ${files}) target_link_libraries(${testcase}_cpp17 PRIVATE ${NLOHMANN_JSON_TARGET_NAME}) target_compile_features(${testcase}_cpp17 PRIVATE cxx_std_17) - if (CMAKE_COMPILER_IS_GNUCC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0 AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0) + if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0 AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0) # fix for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90050 target_link_libraries(${testcase}_cpp17 PRIVATE stdc++fs) endif() From 62c19f239961bae8a6ee837955d4ca77e397fc40 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Tue, 28 Dec 2021 15:22:50 +0100 Subject: [PATCH 37/38] :alembic: use fix from https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90050 --- test/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 1be50994d0..4c741f2743 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -99,7 +99,7 @@ foreach(file ${files}) target_link_libraries(${testcase}_cpp17 PRIVATE ${NLOHMANN_JSON_TARGET_NAME}) target_compile_features(${testcase}_cpp17 PRIVATE cxx_std_17) - if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0 AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0) + if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0 AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0 AND NOT MINGW) # fix for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90050 target_link_libraries(${testcase}_cpp17 PRIVATE stdc++fs) endif() From eba77cdb9666cd35f60b5576a3d6bd95d1afc692 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Tue, 28 Dec 2021 22:51:37 +0100 Subject: [PATCH 38/38] :construction_worker: use published CI image --- .github/workflows/ubuntu.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 60aebd1941..756e82f55a 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -11,7 +11,7 @@ on: jobs: ci_test_clang: runs-on: ubuntu-latest - container: ghcr.io/nlohmann/json-ci:main + container: ghcr.io/nlohmann/json-ci:v2.1.0 steps: - uses: actions/checkout@v2 - name: cmake @@ -21,7 +21,7 @@ jobs: ci_test_gcc: runs-on: ubuntu-latest - container: ghcr.io/nlohmann/json-ci:main + container: ghcr.io/nlohmann/json-ci:v2.1.0 steps: - uses: actions/checkout@v2 - name: cmake @@ -31,7 +31,7 @@ jobs: ci_static_analysis: runs-on: ubuntu-latest - container: ghcr.io/nlohmann/json-ci:main + container: ghcr.io/nlohmann/json-ci:v2.1.0 strategy: matrix: target: [ci_clang_tidy, ci_cppcheck, ci_test_valgrind, ci_test_clang_sanitizer, ci_test_amalgamation, ci_clang_analyze, ci_cpplint, ci_cmake_flags, ci_single_binaries, ci_reproducible_tests, ci_non_git_tests, ci_offline_testdata, ci_infer] @@ -44,7 +44,7 @@ jobs: ci_cmake_options: runs-on: ubuntu-latest - container: ghcr.io/nlohmann/json-ci:main + container: ghcr.io/nlohmann/json-ci:v2.1.0 strategy: matrix: target: [ci_test_diagnostics, ci_test_noexceptions, ci_test_noimplicitconversions] @@ -57,7 +57,7 @@ jobs: ci_test_coverage: runs-on: ubuntu-latest - container: ghcr.io/nlohmann/json-ci:main + container: ghcr.io/nlohmann/json-ci:v2.1.0 steps: - uses: actions/checkout@v2 - name: cmake @@ -77,7 +77,7 @@ jobs: ci_test_compilers: runs-on: ubuntu-latest - container: ghcr.io/nlohmann/json-ci:main + container: ghcr.io/nlohmann/json-ci:v2.1.0 strategy: matrix: compiler: [g++-4.8, g++-4.9, g++-5, g++-6, g++-7, g++-8, g++-9, g++-10, clang++-3.5, clang++-3.6, clang++-3.7, clang++-3.8, clang++-3.9, clang++-4.0, clang++-5.0, clang++-6.0, clang++-7, clang++-8, clang++-9, clang++-10, clang++-11, clang++-12, clang++-13] @@ -90,7 +90,7 @@ jobs: ci_test_standards: runs-on: ubuntu-latest - container: ghcr.io/nlohmann/json-ci:main + container: ghcr.io/nlohmann/json-ci:v2.1.0 strategy: matrix: standard: [11, 14, 17, 20]