Lines 353-358
struct is_compatible_object_type_impl<true, RealType,
Link Here
|
353 |
std::is_constructible<typename RealType::mapped_type, typename CompatibleObjectType::mapped_type>::value; |
353 |
std::is_constructible<typename RealType::mapped_type, typename CompatibleObjectType::mapped_type>::value; |
354 |
}; |
354 |
}; |
355 |
|
355 |
|
|
|
356 |
template<bool B, class RealType, class CompatibleStringType> |
357 |
struct is_compatible_string_type_impl : std::false_type {}; |
358 |
|
359 |
template<class RealType, class CompatibleStringType> |
360 |
struct is_compatible_string_type_impl<true, RealType, CompatibleStringType> |
361 |
{ |
362 |
static constexpr auto value = |
363 |
std::is_same<typename RealType::value_type, typename CompatibleStringType::value_type>::value; |
364 |
}; |
365 |
|
356 |
template<class BasicJsonType, class CompatibleObjectType> |
366 |
template<class BasicJsonType, class CompatibleObjectType> |
357 |
struct is_compatible_object_type |
367 |
struct is_compatible_object_type |
358 |
{ |
368 |
{ |
Lines 363-368
struct is_compatible_object_type
Link Here
|
363 |
typename BasicJsonType::object_t, CompatibleObjectType >::value; |
373 |
typename BasicJsonType::object_t, CompatibleObjectType >::value; |
364 |
}; |
374 |
}; |
365 |
|
375 |
|
|
|
376 |
template<class BasicJsonType, class CompatibleStringType> |
377 |
struct is_compatible_string_type |
378 |
{ |
379 |
static auto constexpr value = is_compatible_string_type_impl < |
380 |
conjunction<negation<std::is_same<void, CompatibleStringType>>, |
381 |
has_value_type<CompatibleStringType>>::value, |
382 |
typename BasicJsonType::string_t, CompatibleStringType >::value; |
383 |
}; |
384 |
|
366 |
template<typename BasicJsonType, typename T> |
385 |
template<typename BasicJsonType, typename T> |
367 |
struct is_basic_json_nested_type |
386 |
struct is_basic_json_nested_type |
368 |
{ |
387 |
{ |
Lines 974-979
void from_json(const BasicJsonType& j, typename BasicJ
Link Here
|
974 |
{ |
993 |
{ |
975 |
JSON_THROW(type_error::create(302, "type must be string, but is " + std::string(j.type_name()))); |
994 |
JSON_THROW(type_error::create(302, "type must be string, but is " + std::string(j.type_name()))); |
976 |
} |
995 |
} |
|
|
996 |
s = *j.template get_ptr<const typename BasicJsonType::string_t*>(); |
997 |
} |
998 |
|
999 |
template < |
1000 |
typename BasicJsonType, typename CompatibleStringType, |
1001 |
enable_if_t < |
1002 |
is_compatible_string_type<BasicJsonType, CompatibleStringType>::value and |
1003 |
not std::is_same<typename BasicJsonType::string_t, |
1004 |
CompatibleStringType>::value and |
1005 |
std::is_constructible < |
1006 |
BasicJsonType, typename CompatibleStringType::value_type >::value, |
1007 |
int > = 0 > |
1008 |
void from_json(const BasicJsonType& j, CompatibleStringType& s) |
1009 |
{ |
1010 |
if (JSON_UNLIKELY(not j.is_string())) |
1011 |
{ |
1012 |
JSON_THROW(type_error::create(302, "type must be string, but is " + std::string(j.type_name()))); |
1013 |
} |
1014 |
|
977 |
s = *j.template get_ptr<const typename BasicJsonType::string_t*>(); |
1015 |
s = *j.template get_ptr<const typename BasicJsonType::string_t*>(); |
978 |
} |
1016 |
} |
979 |
|
1017 |
|