⚗️ do not use too old compilers with C++17
This commit is contained in:
parent
12bb88871e
commit
2b431c212f
@ -19,21 +19,19 @@
|
||||
#include <nlohmann/detail/meta/type_traits.hpp>
|
||||
#include <nlohmann/detail/value_t.hpp>
|
||||
|
||||
#ifdef JSON_STD_FILESYSTEM_EXPERIMENTAL
|
||||
#if JSON_STD_FILESYSTEM_EXPERIMENTAL
|
||||
#if JSON_HAS_EXPERIMENTAL_FILESYSTEM
|
||||
#include <experimental/filesystem>
|
||||
namespace nlohmann::detail
|
||||
{
|
||||
namespace std_fs = std::experimental::filesystem;
|
||||
} // namespace nlohmann::detail
|
||||
#else
|
||||
#elif JSON_HAS_FILESYSTEM
|
||||
#include <filesystem>
|
||||
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<Key, Value, Hash, KeyE
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef JSON_STD_FILESYSTEM_EXPERIMENTAL
|
||||
#if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM
|
||||
template<typename BasicJsonType>
|
||||
void from_json(const BasicJsonType& j, std_fs::path& p)
|
||||
{
|
||||
|
||||
@ -15,21 +15,19 @@
|
||||
#include <nlohmann/detail/meta/type_traits.hpp>
|
||||
#include <nlohmann/detail/value_t.hpp>
|
||||
|
||||
#ifdef JSON_STD_FILESYSTEM_EXPERIMENTAL
|
||||
#if JSON_STD_FILESYSTEM_EXPERIMENTAL
|
||||
#if JSON_HAS_EXPERIMENTAL_FILESYSTEM
|
||||
#include <experimental/filesystem>
|
||||
namespace nlohmann::detail
|
||||
{
|
||||
namespace std_fs = std::experimental::filesystem;
|
||||
} // namespace nlohmann::detail
|
||||
#else
|
||||
#elif JSON_HAS_FILESYSTEM
|
||||
#include <filesystem>
|
||||
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<std::tuple_size<T>::value> {});
|
||||
}
|
||||
|
||||
#ifdef JSON_STD_FILESYSTEM_EXPERIMENTAL
|
||||
#if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM
|
||||
template<typename BasicJsonType>
|
||||
void to_json(BasicJsonType& j, const std_fs::path& p)
|
||||
{
|
||||
|
||||
@ -38,27 +38,33 @@
|
||||
#endif
|
||||
|
||||
#ifdef JSON_HAS_CPP_17
|
||||
// set JSON_STD_FILESYSTEM_EXPERIMENTAL to 1 if <experimental/filesystem> should be taken instead of <filesystem>
|
||||
#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(<filesystem>)
|
||||
#define JSON_STD_FILESYSTEM_EXPERIMENTAL 0
|
||||
#define JSON_HAS_FILESYSTEM 1
|
||||
#elif __has_include(<experimental/filesystem>)
|
||||
#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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -2326,27 +2326,33 @@ using is_detected_convertible =
|
||||
#endif
|
||||
|
||||
#ifdef JSON_HAS_CPP_17
|
||||
// set JSON_STD_FILESYSTEM_EXPERIMENTAL to 1 if <experimental/filesystem> should be taken instead of <filesystem>
|
||||
#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(<filesystem>)
|
||||
#define JSON_STD_FILESYSTEM_EXPERIMENTAL 0
|
||||
#define JSON_HAS_FILESYSTEM 1
|
||||
#elif __has_include(<experimental/filesystem>)
|
||||
#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 <nlohmann/detail/value_t.hpp>
|
||||
|
||||
|
||||
#ifdef JSON_STD_FILESYSTEM_EXPERIMENTAL
|
||||
#if JSON_STD_FILESYSTEM_EXPERIMENTAL
|
||||
#if JSON_HAS_EXPERIMENTAL_FILESYSTEM
|
||||
#include <experimental/filesystem>
|
||||
namespace nlohmann::detail
|
||||
{
|
||||
namespace std_fs = std::experimental::filesystem;
|
||||
} // namespace nlohmann::detail
|
||||
#else
|
||||
#elif JSON_HAS_FILESYSTEM
|
||||
#include <filesystem>
|
||||
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<Key, Value, Hash, KeyE
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef JSON_STD_FILESYSTEM_EXPERIMENTAL
|
||||
#if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM
|
||||
template<typename BasicJsonType>
|
||||
void from_json(const BasicJsonType& j, std_fs::path& p)
|
||||
{
|
||||
@ -4660,21 +4664,19 @@ class tuple_element<N, ::nlohmann::detail::iteration_proxy_value<IteratorType >>
|
||||
// #include <nlohmann/detail/value_t.hpp>
|
||||
|
||||
|
||||
#ifdef JSON_STD_FILESYSTEM_EXPERIMENTAL
|
||||
#if JSON_STD_FILESYSTEM_EXPERIMENTAL
|
||||
#if JSON_HAS_EXPERIMENTAL_FILESYSTEM
|
||||
#include <experimental/filesystem>
|
||||
namespace nlohmann::detail
|
||||
{
|
||||
namespace std_fs = std::experimental::filesystem;
|
||||
} // namespace nlohmann::detail
|
||||
#else
|
||||
#elif JSON_HAS_FILESYSTEM
|
||||
#include <filesystem>
|
||||
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<std::tuple_size<T>::value> {});
|
||||
}
|
||||
|
||||
#ifdef JSON_STD_FILESYSTEM_EXPERIMENTAL
|
||||
#if JSON_HAS_FILESYSTEM || JSON_HAS_EXPERIMENTAL_FILESYSTEM
|
||||
template<typename BasicJsonType>
|
||||
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
|
||||
|
||||
@ -49,42 +49,40 @@ using ordered_json = nlohmann::ordered_json;
|
||||
#ifdef JSON_HAS_CPP_17
|
||||
#include <variant>
|
||||
|
||||
// set JSON_STD_FILESYSTEM_EXPERIMENTAL to 1 if <experimental/filesystem> should be taken instead of <filesystem>
|
||||
#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(<filesystem>)
|
||||
#define JSON_STD_FILESYSTEM_EXPERIMENTAL 0
|
||||
#elif __has_include(<experimental/filesystem>)
|
||||
#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(<filesystem>)
|
||||
#define JSON_HAS_FILESYSTEM 1
|
||||
#elif __has_include(<experimental/filesystem>)
|
||||
#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 <experimental/filesystem>
|
||||
namespace nlohmann::detail
|
||||
{
|
||||
namespace std_fs = std::experimental::filesystem;
|
||||
} // namespace nlohmann::detail
|
||||
#else
|
||||
#elif JSON_HAS_FILESYSTEM
|
||||
#include <filesystem>
|
||||
namespace nlohmann::detail
|
||||
{
|
||||
namespace std_fs = std::filesystem;
|
||||
} // namespace nlohmann::detail
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef JSON_HAS_CPP_20
|
||||
#include <span>
|
||||
@ -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");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user