mirror of
https://github.com/nlohmann/json.git
synced 2024-08-23 21:42:29 +02:00
correctly constrain basic_json udt constructor
This commit is contained in:
parent
0d91113ccf
commit
e2dbe7a69f
24
src/json.hpp
24
src/json.hpp
|
@ -512,7 +512,7 @@ class basic_json
|
||||||
/// workaround type for MSVC
|
/// workaround type for MSVC
|
||||||
using basic_json_t = basic_json<ObjectType, ArrayType, StringType,
|
using basic_json_t = basic_json<ObjectType, ArrayType, StringType,
|
||||||
BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType,
|
BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType,
|
||||||
AllocatorType>;
|
AllocatorType, JSONSerializer>;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// forward declarations
|
// forward declarations
|
||||||
|
@ -1565,15 +1565,19 @@ class basic_json
|
||||||
}
|
}
|
||||||
|
|
||||||
// constructor chosen when JSONSerializer::to_json exists for type T
|
// constructor chosen when JSONSerializer::to_json exists for type T
|
||||||
template <typename T, enable_if_t<detail::has_to_json<
|
template <typename T, enable_if_t<detail::conjunction<detail::negation<std::is_same<uncvref_t<T>, basic_json_t>>,
|
||||||
JSONSerializer, basic_json, uncvref_t<T>>::value and not (detail::is_compatible_object_type<object_t, uncvref_t<T>>::value or
|
detail::negation<detail::disjunction<
|
||||||
detail::is_compatible_array_type<basic_json_t, uncvref_t<T>>::value or
|
detail::is_compatible_array_type<basic_json_t, uncvref_t<T>>,
|
||||||
detail::is_compatible_float_type<number_float_t, uncvref_t<T>>::value or
|
detail::is_compatible_object_type<object_t, uncvref_t<T>>,
|
||||||
detail::is_compatible_integer_type<number_integer_t, uncvref_t<T>>::value or
|
detail::is_compatible_float_type<number_float_t, uncvref_t<T>>,
|
||||||
detail::is_compatible_unsigned_integer_type<number_unsigned_t, uncvref_t<T>>::value or
|
detail::is_compatible_integer_type<number_integer_t, uncvref_t<T>>,
|
||||||
std::is_constructible<string_t, uncvref_t<T>>::value or
|
detail::is_compatible_unsigned_integer_type<number_unsigned_t, uncvref_t<T>>,
|
||||||
std::is_base_of<std::istream, uncvref_t<T>>::value or
|
std::is_constructible<string_t, uncvref_t<T>>,
|
||||||
std::is_same<boolean_t, uncvref_t<T>>::value), int> = 0>
|
std::is_base_of<std::istream, uncvref_t<T>>,
|
||||||
|
std::is_same<boolean_t, uncvref_t<T>>>>,
|
||||||
|
detail::has_to_json<
|
||||||
|
JSONSerializer, basic_json, uncvref_t<T>>
|
||||||
|
>::value, int> = 0>
|
||||||
explicit basic_json(T &&val)
|
explicit basic_json(T &&val)
|
||||||
{
|
{
|
||||||
JSONSerializer<uncvref_t<T>>::to_json(*this, std::forward<T>(val));
|
JSONSerializer<uncvref_t<T>>::to_json(*this, std::forward<T>(val));
|
||||||
|
|
Loading…
Reference in a new issue