mirror of
https://github.com/nlohmann/json.git
synced 2026-02-20 02:16:24 +00:00
Compare commits
5 Commits
develop
...
views-test
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8e8b1b4883 | ||
|
|
39c59b89be | ||
|
|
c4c1820c47 | ||
|
|
6cbf2b205a | ||
|
|
b4a5a4fbbc |
31
cmake/detect_libcpp_version.cpp
Normal file
31
cmake/detect_libcpp_version.cpp
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* Detect used C++ Standard Library
|
||||||
|
*
|
||||||
|
* This file is compiled and run via try_run in download_test_data.cmake.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <cstdio>
|
||||||
|
|
||||||
|
// see https://en.cppreference.com/w/cpp/header/ciso646
|
||||||
|
#if __cplusplus >= 202002L
|
||||||
|
#include <version>
|
||||||
|
#else
|
||||||
|
#include <ciso646>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
#if defined(_LIBCPP_VERSION)
|
||||||
|
std::printf("LLVM C++ Standard Library (libc++), _LIBCPP_VERSION=%d", _LIBCPP_VERSION);
|
||||||
|
#elif defined(__GLIBCXX__)
|
||||||
|
std::printf("GNU C++ Standard Library (libstdc++), __GLIBCXX__=%d", __GLIBCXX__);
|
||||||
|
#elif defined(_MSVC_STL_VERSION)
|
||||||
|
std::printf("Microsoft C++ Standard Library (MSVC STL), _MSVC_STL_VERSION=%d", _MSVC_STL_VERSION);
|
||||||
|
#elif defined(_LIBCUDACXX_VERSION)
|
||||||
|
std::printf("NVIDIA C++ Standard Library (libcudacxx), _LIBCUDACXX_VERSION=%d", _LIBCUDACXX_VERSION);
|
||||||
|
#elif defined(EASTL_VERSION)
|
||||||
|
std::printf("Electronic Arts Standard Template Library (EASTL), EASTL_VERSION=%d", EASTL_VERSION);
|
||||||
|
#else
|
||||||
|
std::printf("unknown");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
@@ -54,3 +54,18 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
string(REGEX REPLACE "[ ]*\n" "; " CXX_VERSION_RESULT "${CXX_VERSION_RESULT}")
|
string(REGEX REPLACE "[ ]*\n" "; " CXX_VERSION_RESULT "${CXX_VERSION_RESULT}")
|
||||||
message(STATUS "Compiler: ${CXX_VERSION_RESULT}")
|
message(STATUS "Compiler: ${CXX_VERSION_RESULT}")
|
||||||
|
|
||||||
|
# determine used C++ standard library (for debug and support purposes)
|
||||||
|
if(NOT DEFINED LIBCPP_VERSION_OUTPUT_CACHED)
|
||||||
|
try_run(RUN_RESULT_VAR COMPILE_RESULT_VAR
|
||||||
|
"${CMAKE_BINARY_DIR}" SOURCES "${CMAKE_SOURCE_DIR}/cmake/detect_libcpp_version.cpp"
|
||||||
|
RUN_OUTPUT_VARIABLE LIBCPP_VERSION_OUTPUT COMPILE_OUTPUT_VARIABLE LIBCPP_VERSION_COMPILE_OUTPUT
|
||||||
|
)
|
||||||
|
if(NOT LIBCPP_VERSION_OUTPUT)
|
||||||
|
set(LIBCPP_VERSION_OUTPUT "Unknown")
|
||||||
|
message(AUTHOR_WARNING "Failed to compile cmake/detect_libcpp_version to detect the used C++ standard library. This does not affect the library or the test cases. Please still create an issue at https://github.com/nlohmann/json to investigate this.\n${LIBCPP_VERSION_COMPILE_OUTPUT}")
|
||||||
|
endif()
|
||||||
|
set(LIBCPP_VERSION_OUTPUT_CACHED "${LIBCPP_VERSION_OUTPUT}" CACHE STRING "Detected C++ standard library version")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
message(STATUS "C++ standard library: ${LIBCPP_VERSION_OUTPUT_CACHED}")
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ Note `/` does not identify the root (i.e., the whole document), but an object en
|
|||||||
JSON Pointers can be created from a string:
|
JSON Pointers can be created from a string:
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
json::json_pointer p = "/nested/one";
|
json::json_pointer p("/nested/one");
|
||||||
```
|
```
|
||||||
|
|
||||||
Furthermore, a user-defined string literal can be used to achieve the same result:
|
Furthermore, a user-defined string literal can be used to achieve the same result:
|
||||||
|
|||||||
@@ -1914,10 +1914,12 @@ TEST_CASE("MessagePack with std::byte")
|
|||||||
SECTION("empty vector")
|
SECTION("empty vector")
|
||||||
{
|
{
|
||||||
const std::vector<std::byte> empty_data;
|
const std::vector<std::byte> empty_data;
|
||||||
CHECK_THROWS_WITH_AS([&]() {
|
CHECK_THROWS_WITH_AS([&]()
|
||||||
|
{
|
||||||
[[maybe_unused]] auto result = json::from_msgpack(empty_data);
|
[[maybe_unused]] auto result = json::from_msgpack(empty_data);
|
||||||
return true;
|
return true;
|
||||||
}(),
|
}
|
||||||
|
(),
|
||||||
"[json.exception.parse_error.110] parse error at byte 1: syntax error while parsing MessagePack value: unexpected end of input",
|
"[json.exception.parse_error.110] parse error at byte 1: syntax error while parsing MessagePack value: unexpected end of input",
|
||||||
json::parse_error&);
|
json::parse_error&);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,6 +50,11 @@ using ordered_json = nlohmann::ordered_json;
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// for #4440
|
||||||
|
#if JSON_HAS_RANGES == 1
|
||||||
|
#include <ranges>
|
||||||
|
#endif
|
||||||
|
|
||||||
// NLOHMANN_JSON_SERIALIZE_ENUM uses a static std::pair
|
// NLOHMANN_JSON_SERIALIZE_ENUM uses a static std::pair
|
||||||
DOCTEST_CLANG_SUPPRESS_WARNING_PUSH
|
DOCTEST_CLANG_SUPPRESS_WARNING_PUSH
|
||||||
DOCTEST_CLANG_SUPPRESS_WARNING("-Wexit-time-destructors")
|
DOCTEST_CLANG_SUPPRESS_WARNING("-Wexit-time-destructors")
|
||||||
@@ -1094,6 +1099,20 @@ TEST_CASE("regression tests 2")
|
|||||||
CHECK(j.type_name() == "invalid");
|
CHECK(j.type_name() == "invalid");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#if JSON_HAS_RANGES == 1
|
||||||
|
SECTION("issue 4440")
|
||||||
|
{
|
||||||
|
auto noOpFilter = std::views::filter([](auto&&) noexcept
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
json j = {1, 2, 3};
|
||||||
|
auto filtered = j | noOpFilter;
|
||||||
|
CHECK(*filtered.begin() == 1);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
DOCTEST_CLANG_SUPPRESS_WARNING_POP
|
DOCTEST_CLANG_SUPPRESS_WARNING_POP
|
||||||
|
|||||||
Reference in New Issue
Block a user