refactor is_compatible_array_type

This commit is contained in:
Théo DELRIEU 2018-09-05 16:49:27 +02:00
parent 924e95c6e8
commit 13760857ff
No known key found for this signature in database
GPG key ID: A5A505438C20539A
2 changed files with 34 additions and 22 deletions

View file

@ -117,20 +117,26 @@ struct is_basic_json_nested_type
std::is_same<T, typename BasicJsonType::const_reverse_iterator>::value; std::is_same<T, typename BasicJsonType::const_reverse_iterator>::value;
}; };
template<class BasicJsonType, class CompatibleArrayType> template <typename BasicJsonType, typename CompatibleArrayType, typename = void>
struct is_compatible_array_type struct is_compatible_array_type_impl : std::false_type {};
template <typename BasicJsonType, typename CompatibleArrayType>
struct is_compatible_array_type_impl <
BasicJsonType, CompatibleArrayType,
enable_if_t<is_detected<value_type_t, CompatibleArrayType>::value and
is_detected<iterator_t, CompatibleArrayType>::value >>
{ {
static auto constexpr value = static constexpr auto value = not(
conjunction<negation<std::is_same<void, CompatibleArrayType>>, is_compatible_object_type<BasicJsonType, CompatibleArrayType>::value or
negation<is_compatible_object_type< std::is_constructible<typename BasicJsonType::string_t,
BasicJsonType, CompatibleArrayType>>, CompatibleArrayType>::value or
negation<std::is_constructible<typename BasicJsonType::string_t, is_basic_json_nested_type<BasicJsonType, CompatibleArrayType>::value);
CompatibleArrayType>>,
negation<is_basic_json_nested_type<BasicJsonType, CompatibleArrayType>>,
is_detected<value_type_t, CompatibleArrayType>,
is_detected<iterator_t, CompatibleArrayType>>::value;
}; };
template <typename BasicJsonType, typename CompatibleArrayType>
struct is_compatible_array_type
: is_compatible_array_type_impl<BasicJsonType, CompatibleArrayType> {};
template<bool, typename, typename> template<bool, typename, typename>
struct is_compatible_integer_type_impl : std::false_type {}; struct is_compatible_integer_type_impl : std::false_type {};

View file

@ -497,20 +497,26 @@ struct is_basic_json_nested_type
std::is_same<T, typename BasicJsonType::const_reverse_iterator>::value; std::is_same<T, typename BasicJsonType::const_reverse_iterator>::value;
}; };
template<class BasicJsonType, class CompatibleArrayType> template <typename BasicJsonType, typename CompatibleArrayType, typename = void>
struct is_compatible_array_type struct is_compatible_array_type_impl : std::false_type {};
template <typename BasicJsonType, typename CompatibleArrayType>
struct is_compatible_array_type_impl <
BasicJsonType, CompatibleArrayType,
enable_if_t<is_detected<value_type_t, CompatibleArrayType>::value and
is_detected<iterator_t, CompatibleArrayType>::value >>
{ {
static auto constexpr value = static constexpr auto value = not(
conjunction<negation<std::is_same<void, CompatibleArrayType>>, is_compatible_object_type<BasicJsonType, CompatibleArrayType>::value or
negation<is_compatible_object_type< std::is_constructible<typename BasicJsonType::string_t,
BasicJsonType, CompatibleArrayType>>, CompatibleArrayType>::value or
negation<std::is_constructible<typename BasicJsonType::string_t, is_basic_json_nested_type<BasicJsonType, CompatibleArrayType>::value);
CompatibleArrayType>>,
negation<is_basic_json_nested_type<BasicJsonType, CompatibleArrayType>>,
is_detected<value_type_t, CompatibleArrayType>,
is_detected<iterator_t, CompatibleArrayType>>::value;
}; };
template <typename BasicJsonType, typename CompatibleArrayType>
struct is_compatible_array_type
: is_compatible_array_type_impl<BasicJsonType, CompatibleArrayType> {};
template<bool, typename, typename> template<bool, typename, typename>
struct is_compatible_integer_type_impl : std::false_type {}; struct is_compatible_integer_type_impl : std::false_type {};