diff --git a/src/json.hpp b/src/json.hpp index d8f337599..703a1e023 100644 --- a/src/json.hpp +++ b/src/json.hpp @@ -150,6 +150,96 @@ struct has_mapped_type std::is_integral()))>::value; }; +template +struct has_key_type +{ + private: + template + static int detect(U&&); + + static void detect(...); + public: + static constexpr bool value = + std::is_integral()))>::value; +}; + +template +struct has_value_type +{ + private: + template + static int detect(U&&); + + static void detect(...); + public: + static constexpr bool value = + std::is_integral()))>::value; +}; + +template +struct is_compatible_object_type_impl : std::false_type{}; + +template +struct is_compatible_object_type_impl +{ + static constexpr auto value = + std::is_constructible::value and + std::is_constructible::value; +}; + +template::value and has_key_type::value>> +struct is_compatible_object_type +{ + static auto constexpr value = is_compatible_object_type_impl::value and has_key_type::value, RealType, CompatibleObjectType>::value; +}; + +template +struct is_compatible_array_type_impl : std::false_type{}; + +template +struct is_compatible_array_type_impl +{ + static constexpr auto value = + not std::is_same::value and + not std::is_same::value and + not std::is_same::value and + not std::is_same::value and + not std::is_same::value and + not std::is_same::value and + std::is_constructible::value; + +}; + +template +struct is_compatible_array_type +{ + static auto constexpr value = is_compatible_array_type_impl::value, BasicJson, CompatibleArrayType>::value; +}; + +template +struct is_compatible_integer_type +{ + static constexpr auto value = + std::is_constructible::value and + std::numeric_limits::is_integer and + std::numeric_limits::is_signed; +}; + +template +struct is_compatible_unsigned_integer_type +{ + static constexpr auto value = std::is_constructible::value and + std::numeric_limits::is_integer and + not std::numeric_limits::is_signed; +}; + +template +struct is_compatible_float_type +{ + static constexpr auto value = std::is_constructible::value and + std::is_floating_point::value; +}; + template