Fix CI: include cycle, GCC 4.8 literal operator spacing, and global UDLs off in the JSON_NO_AUTOMATIC_UDLS test
- Suppress clang-tidy misc-header-include-cycle on the intentional mutual include of json.hpp and json_literals.hpp. - Use operator"" _json with a space for GCC 4.8 in the test's detection aliases, as the header does. - Only test the global literal operators when JSON_USE_GLOBAL_UDLS is on. Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
5 files changed
+20
-4
No files matched your search
@@ -6569,6 +6569,7 @@ struct formatter<nlohmann::NLOHMANN_BASIC_JSON_TPL, char> // NOLINT(cert-dcl58-c
|
|||||||
// Define JSON_NO_AUTOMATIC_UDLS to include <nlohmann/json_literals.hpp> only
|
// Define JSON_NO_AUTOMATIC_UDLS to include <nlohmann/json_literals.hpp> only
|
||||||
// where needed.
|
// where needed.
|
||||||
#ifndef JSON_NO_AUTOMATIC_UDLS
|
#ifndef JSON_NO_AUTOMATIC_UDLS
|
||||||
|
// NOLINTNEXTLINE(misc-header-include-cycle): json_literals.hpp includes this header
|
||||||
#include <nlohmann/json_literals.hpp>
|
#include <nlohmann/json_literals.hpp>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
#include <cstddef> // size_t
|
#include <cstddef> // size_t
|
||||||
#include <string> // string
|
#include <string> // string
|
||||||
|
|
||||||
|
// NOLINTNEXTLINE(misc-header-include-cycle): json.hpp includes this header at its end
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
// This header is included at the end of <nlohmann/json.hpp> unless
|
// This header is included at the end of <nlohmann/json.hpp> unless
|
||||||
|
|||||||
@@ -32859,6 +32859,7 @@ struct formatter<nlohmann::NLOHMANN_BASIC_JSON_TPL, char> // NOLINT(cert-dcl58-c
|
|||||||
// Define JSON_NO_AUTOMATIC_UDLS to include <nlohmann/json_literals.hpp> only
|
// Define JSON_NO_AUTOMATIC_UDLS to include <nlohmann/json_literals.hpp> only
|
||||||
// where needed.
|
// where needed.
|
||||||
#ifndef JSON_NO_AUTOMATIC_UDLS
|
#ifndef JSON_NO_AUTOMATIC_UDLS
|
||||||
|
// NOLINTNEXTLINE(misc-header-include-cycle): json_literals.hpp includes this header
|
||||||
// #include <nlohmann/json_literals.hpp>
|
// #include <nlohmann/json_literals.hpp>
|
||||||
// __ _____ _____ _____
|
// __ _____ _____ _____
|
||||||
// __| | __| | | | JSON for Modern C++
|
// __| | __| | | | JSON for Modern C++
|
||||||
@@ -32874,6 +32875,7 @@ struct formatter<nlohmann::NLOHMANN_BASIC_JSON_TPL, char> // NOLINT(cert-dcl58-c
|
|||||||
#include <cstddef> // size_t
|
#include <cstddef> // size_t
|
||||||
#include <string> // string
|
#include <string> // string
|
||||||
|
|
||||||
|
// NOLINTNEXTLINE(misc-header-include-cycle): json.hpp includes this header at its end
|
||||||
// #include <nlohmann/json.hpp>
|
// #include <nlohmann/json.hpp>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
#include <cstddef> // size_t
|
#include <cstddef> // size_t
|
||||||
#include <string> // string
|
#include <string> // string
|
||||||
|
|
||||||
|
// NOLINTNEXTLINE(misc-header-include-cycle): json.hpp includes this header at its end
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
// This header is included at the end of <nlohmann/json.hpp> unless
|
// This header is included at the end of <nlohmann/json.hpp> unless
|
||||||
|
|||||||
@@ -41,11 +41,20 @@ namespace
|
|||||||
// deferred to the point of instantiation, where it considers the declarations
|
// deferred to the point of instantiation, where it considers the declarations
|
||||||
// visible from here (the global using-declarations of JSON_USE_GLOBAL_UDLS) plus
|
// visible from here (the global using-declarations of JSON_USE_GLOBAL_UDLS) plus
|
||||||
// argument-dependent lookup (the literals in the library namespace).
|
// argument-dependent lookup (the literals in the library namespace).
|
||||||
template<typename T>
|
#if !defined(__GNUC__) || defined(__clang__) || __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 9)
|
||||||
using json_udl_t = decltype(operator""_json(std::declval<T>(), std::size_t()));
|
template<typename T>
|
||||||
|
using json_udl_t = decltype(operator""_json(std::declval<T>(), std::size_t()));
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
using json_pointer_udl_t = decltype(operator""_json_pointer(std::declval<T>(), std::size_t()));
|
using json_pointer_udl_t = decltype(operator""_json_pointer(std::declval<T>(), std::size_t()));
|
||||||
|
#else
|
||||||
|
// GCC 4.8 requires a space between "" and suffix
|
||||||
|
template<typename T>
|
||||||
|
using json_udl_t = decltype(operator"" _json(std::declval<T>(), std::size_t()));
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
using json_pointer_udl_t = decltype(operator"" _json_pointer(std::declval<T>(), std::size_t()));
|
||||||
|
#endif
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
using has_json_udl = nlohmann::detail::is_detected<json_udl_t, T>;
|
using has_json_udl = nlohmann::detail::is_detected<json_udl_t, T>;
|
||||||
@@ -83,11 +92,13 @@ TEST_CASE("JSON_NO_AUTOMATIC_UDLS")
|
|||||||
|
|
||||||
TEST_CASE("JSON_NO_AUTOMATIC_UDLS with <nlohmann/json_literals.hpp>")
|
TEST_CASE("JSON_NO_AUTOMATIC_UDLS with <nlohmann/json_literals.hpp>")
|
||||||
{
|
{
|
||||||
|
#if !defined(JSON_USE_GLOBAL_UDLS) || JSON_USE_GLOBAL_UDLS
|
||||||
SECTION("global namespace")
|
SECTION("global namespace")
|
||||||
{
|
{
|
||||||
CHECK("[1,2]"_json == json({1, 2}));
|
CHECK("[1,2]"_json == json({1, 2}));
|
||||||
CHECK("/a/0"_json_pointer == json::json_pointer("/a/0"));
|
CHECK("/a/0"_json_pointer == json::json_pointer("/a/0"));
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
SECTION("nlohmann::literals::json_literals")
|
SECTION("nlohmann::literals::json_literals")
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in new issue
Block a user