From 7fc4b2901a3bf4e5b43b7bae1cca2b314630d4ea Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Fri, 17 Jul 2020 20:41:11 +0200 Subject: [PATCH] :children_crossing: add static assertion for missing binary function in SAX interface --- include/nlohmann/detail/meta/is_sax.hpp | 19 +++++++++++++------ single_include/nlohmann/json.hpp | 19 +++++++++++++------ 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/include/nlohmann/detail/meta/is_sax.hpp b/include/nlohmann/detail/meta/is_sax.hpp index 53e96ebb..e1e48a0b 100644 --- a/include/nlohmann/detail/meta/is_sax.hpp +++ b/include/nlohmann/detail/meta/is_sax.hpp @@ -34,6 +34,10 @@ template using string_function_t = decltype(std::declval().string(std::declval())); +template +using binary_function_t = + decltype(std::declval().binary(std::declval())); + template using start_object_function_t = decltype(std::declval().start_object(std::declval())); @@ -68,19 +72,18 @@ struct is_sax using number_unsigned_t = typename BasicJsonType::number_unsigned_t; using number_float_t = typename BasicJsonType::number_float_t; using string_t = typename BasicJsonType::string_t; + using binary_t = typename BasicJsonType::binary_t; using exception_t = typename BasicJsonType::exception; public: static constexpr bool value = is_detected_exact::value && is_detected_exact::value && - is_detected_exact::value && - is_detected_exact::value && - is_detected_exact::value && + is_detected_exact::value && + is_detected_exact::value && + is_detected_exact::value && is_detected_exact::value && + is_detected_exact::value && is_detected_exact::value && is_detected_exact::value && is_detected_exact::value && @@ -100,6 +103,7 @@ struct is_sax_static_asserts using number_unsigned_t = typename BasicJsonType::number_unsigned_t; using number_float_t = typename BasicJsonType::number_float_t; using string_t = typename BasicJsonType::string_t; + using binary_t = typename BasicJsonType::binary_t; using exception_t = typename BasicJsonType::exception; public: @@ -123,6 +127,9 @@ struct is_sax_static_asserts static_assert( is_detected_exact::value, "Missing/invalid function: bool string(string_t&)"); + static_assert( + is_detected_exact::value, + "Missing/invalid function: bool binary(binary_t&)"); static_assert(is_detected_exact::value, "Missing/invalid function: bool start_object(std::size_t)"); static_assert(is_detected_exact::value, diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 1d8b5fb6..4700a112 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -5774,6 +5774,10 @@ template using string_function_t = decltype(std::declval().string(std::declval())); +template +using binary_function_t = + decltype(std::declval().binary(std::declval())); + template using start_object_function_t = decltype(std::declval().start_object(std::declval())); @@ -5808,19 +5812,18 @@ struct is_sax using number_unsigned_t = typename BasicJsonType::number_unsigned_t; using number_float_t = typename BasicJsonType::number_float_t; using string_t = typename BasicJsonType::string_t; + using binary_t = typename BasicJsonType::binary_t; using exception_t = typename BasicJsonType::exception; public: static constexpr bool value = is_detected_exact::value && is_detected_exact::value && - is_detected_exact::value && - is_detected_exact::value && - is_detected_exact::value && + is_detected_exact::value && + is_detected_exact::value && + is_detected_exact::value && is_detected_exact::value && + is_detected_exact::value && is_detected_exact::value && is_detected_exact::value && is_detected_exact::value && @@ -5840,6 +5843,7 @@ struct is_sax_static_asserts using number_unsigned_t = typename BasicJsonType::number_unsigned_t; using number_float_t = typename BasicJsonType::number_float_t; using string_t = typename BasicJsonType::string_t; + using binary_t = typename BasicJsonType::binary_t; using exception_t = typename BasicJsonType::exception; public: @@ -5863,6 +5867,9 @@ struct is_sax_static_asserts static_assert( is_detected_exact::value, "Missing/invalid function: bool string(string_t&)"); + static_assert( + is_detected_exact::value, + "Missing/invalid function: bool binary(binary_t&)"); static_assert(is_detected_exact::value, "Missing/invalid function: bool start_object(std::size_t)"); static_assert(is_detected_exact::value,