From b0785ddce62e34d0c158a3597fed90f2edd4e0a0 Mon Sep 17 00:00:00 2001 From: MistEO Date: Tue, 23 Jan 2024 17:11:49 +0800 Subject: [PATCH] fix: build error for more `is` and `as` cd4a67dacf61fd6628bd5a44b626891bbd5c6776 --- include/json.hpp | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/include/json.hpp b/include/json.hpp index d35ef09..2208d05 100644 --- a/include/json.hpp +++ b/include/json.hpp @@ -43,6 +43,22 @@ namespace utils using iter_value_t = typename std::iterator_traits>::value_type; template using range_value_t = iter_value_t>; + + template + constexpr bool is_container = false; + template + constexpr bool is_container>> = + std::is_same_v>; + + template + constexpr bool is_map = false; + template + constexpr bool is_map> = is_container; + + template + constexpr bool is_collection = false; + template + constexpr bool is_collection = is_container && !is_map; } // ********************************* @@ -205,13 +221,13 @@ class basic_value // deprecated, please use as_collection instead. vector_t to_vector() const { - return template to_vector(); + return to_vector(); } template typename map_t = std::map> // deprecated, please use as_map instead. map_t to_map() const { - return template as_map(); + return as_map(); } basic_value& operator=(const basic_value& rhs); @@ -254,13 +270,13 @@ class basic_value explicit operator string_t() const { return as_string(); } template typename collection_t = std::vector, - typename _ = std::enable_if_t<_serialization_helper::is_collection>>> + typename _ = std::enable_if_t>>> explicit operator collection_t() const { return as_collection(); } template typename map_t = std::map, - typename _ = std::enable_if_t<_serialization_helper::is_map>>> + typename _ = std::enable_if_t>>> explicit operator map_t() const { return as_map(); @@ -767,13 +783,13 @@ inline bool basic_value::is() const noexcept else if constexpr (std::is_same_v, value_t>) { return is_array(); } - else if constexpr (_serialization_helper::is_collection) { + else if constexpr (utils::is_collection) { return is_array() && all(); } else if constexpr (std::is_same_v, value_t>) { return is_object(); } - else if constexpr (_serialization_helper::is_map) { + else if constexpr (utils::is_map) { return is_object() && std::is_constructible_v && all(); } @@ -2619,22 +2635,6 @@ namespace _serialization_helper static constexpr bool value = decltype(test(0))::value; }; - template - constexpr bool is_container = false; - template - constexpr bool is_container>> = - std::is_same_v>; - - template - constexpr bool is_map = false; - template - constexpr bool is_map> = is_container; - - template - constexpr bool is_collection = false; - template - constexpr bool is_collection = is_container && !is_map; - template struct string_converter { @@ -2697,7 +2697,7 @@ basic_value serialize(any_t&& arg, string_converter_t&& string_convert else if constexpr (std::decay_t::template is_convertible) { return string_converter(std::forward(arg)); } - else if constexpr (is_collection>) { + else if constexpr (utils::is_collection>) { basic_value result; for (auto&& val : arg) { using value_t = decltype(val); @@ -2707,7 +2707,7 @@ basic_value serialize(any_t&& arg, string_converter_t&& string_convert } return result; } - else if constexpr (is_map>) { + else if constexpr (utils::is_map>) { basic_value result; for (auto&& [key, val] : arg) { using key_t = decltype(key);