Tidying up the code

This commit is contained in:
Muhammad Amir bin Mohamad Ghazaly 2024-12-06 23:49:32 -05:00
parent 340831ea54
commit 56f17665f1
3 changed files with 16 additions and 14 deletions

View File

@ -325,9 +325,9 @@ inline void from_json(const BasicJsonType& j, typename BasicJsonType::binary_t&
bin = *j.template get_ptr<const typename BasicJsonType::binary_t*>();
}
template < typename BasicJsonType, typename ConstructibleObjectType,
enable_if_t < is_constructible_object_type<BasicJsonType, ConstructibleObjectType>::value&&
!std::is_enum<typename ConstructibleObjectType::key_type>::value, int > = 0 >
template<typename BasicJsonType, typename ConstructibleObjectType,
enable_if_t<is_constructible_object_type<BasicJsonType, ConstructibleObjectType>::value&&
!std::is_enum<typename ConstructibleObjectType::key_type>::value, int> = 0>
inline void from_json(const BasicJsonType& j, ConstructibleObjectType& obj)
{
if (JSON_HEDLEY_UNLIKELY(!j.is_object()))
@ -348,10 +348,10 @@ inline void from_json(const BasicJsonType& j, ConstructibleObjectType& obj)
obj = std::move(ret);
}
template < typename BasicJsonType, typename Key, typename Value, typename Compare, typename Allocator,
enable_if_t < is_constructible_object_type<BasicJsonType, std::map<Key, Value, Compare, Allocator>>::value&&
is_compatible_object_type<BasicJsonType, std::map<Key, Value, Compare, Allocator>>::value&&
std::is_enum<Key>::value, int > = 0 >
template <typename BasicJsonType, typename Key, typename Value, typename Compare, typename Allocator,
enable_if_t<is_constructible_object_type<BasicJsonType, std::map<Key, Value, Compare, Allocator>>::value&&
is_compatible_object_type<BasicJsonType, std::map<Key, Value, Compare, Allocator>>::value&&
std::is_enum<Key>::value, int> = 0>
inline void from_json(const BasicJsonType& j, std::map<Key, Value, Compare, Allocator>& m)
{
if (JSON_HEDLEY_UNLIKELY(!j.is_object()))
@ -361,7 +361,7 @@ inline void from_json(const BasicJsonType& j, std::map<Key, Value, Compare, Allo
m.clear();
for (const auto& p : j.items())
{
m.emplace(string_to_enum(json(p.key()), Key()), p.value().template get<Value>());
m.emplace(string_to_enum(json(p.key()),Key()), p.value().template get<Value>());
}
}
@ -459,7 +459,7 @@ auto from_json(BasicJsonType&& j, TupleRelated&& t)
template < typename BasicJsonType, typename Key, typename Value, typename Compare, typename Allocator,
typename = enable_if_t < !std::is_constructible <
typename BasicJsonType::string_t, Key >::value &&
!is_compatible_object_type<BasicJsonType, std::map<Key, Value, Compare, Allocator>>::value >>
!is_compatible_object_type<BasicJsonType, std::map<Key, Value, Compare, Allocator>>::value>>
inline void from_json(const BasicJsonType& j, std::map<Key, Value, Compare, Allocator>& m)
{
if (JSON_HEDLEY_UNLIKELY(!j.is_array()))

View File

@ -270,7 +270,8 @@ struct external_constructor<value_t::object>
template < typename BasicJsonType, typename CompatibleObjectType,
enable_if_t < !std::is_same<CompatibleObjectType, typename BasicJsonType::object_t>::value&&
is_compatible_object_type<BasicJsonType, CompatibleObjectType>::value&& !is_basic_json<CompatibleObjectType>::value&&
is_compatible_object_type<BasicJsonType, CompatibleObjectType>::value&&
!is_basic_json<CompatibleObjectType>::value&&
!std::is_enum<typename CompatibleObjectType::key_type>::value, int > = 0 >
static void construct(BasicJsonType& j, const CompatibleObjectType& obj)
{
@ -409,7 +410,8 @@ inline void to_json(BasicJsonType& j, typename BasicJsonType::array_t&& arr)
}
template < typename BasicJsonType, typename CompatibleObjectType,
enable_if_t < is_compatible_object_type<BasicJsonType, CompatibleObjectType>::value&& !is_basic_json<CompatibleObjectType>::value&&
enable_if_t < is_compatible_object_type<BasicJsonType, CompatibleObjectType>::value&&
!is_basic_json<CompatibleObjectType>::value&&
!std::is_enum<typename CompatibleObjectType::key_type>::value, int > = 0 >
inline void to_json(BasicJsonType& j, const CompatibleObjectType& obj)
{
@ -417,8 +419,8 @@ inline void to_json(BasicJsonType& j, const CompatibleObjectType& obj)
}
template < typename BasicJsonType, typename Key, typename Value,
enable_if_t < (is_compatible_object_type<BasicJsonType, std::map<Key, Value>>::value)&&
(!is_basic_json<std::map<Key, Value>>::value)&&
enable_if_t < is_compatible_object_type<BasicJsonType, std::map<Key, Value>>::value&&
!is_basic_json<std::map<Key, Value>>::value&&
std::is_enum<Key>::value, int > = 0 >
inline void to_json(BasicJsonType& j, const std::map<Key, Value>& obj)
{

View File

@ -386,7 +386,7 @@ struct is_constructible_object_type_impl <
(std::is_move_assignable<ConstructibleObjectType>::value ||
std::is_copy_assignable<ConstructibleObjectType>::value) &&
(is_constructible<typename ConstructibleObjectType::key_type,
typename object_t::key_type>::value &&
typename object_t::key_type>::value &&
std::is_same <
typename object_t::mapped_type,
typename ConstructibleObjectType::mapped_type >::value)) ||