Commit 4f71075e authored by Dominik Charousset's avatar Dominik Charousset

Detect std::set as list-like container

parent 5d4f8645
...@@ -53,11 +53,12 @@ ...@@ -53,11 +53,12 @@
class has_##name##_alias { \ class has_##name##_alias { \
private: \ private: \
template <class C> \ template <class C> \
static std::true_type sfinae(C* ptr, typename C::name* arg = nullptr); \ static std::true_type sfinae(typename C::name*); \
\ \
static std::false_type sfinae(void* ptr); \ template <class> \
static std::false_type sfinae(...); \
\ \
using sfinae_type = decltype(sfinae(static_cast<T*>(nullptr))); \ using sfinae_type = decltype(sfinae<T>(nullptr)); \
\ \
public: \ public: \
static constexpr bool value = sfinae_type::value; \ static constexpr bool value = sfinae_type::value; \
...@@ -768,7 +769,7 @@ CAF_HAS_ALIAS_TRAIT(mapped_type); ...@@ -768,7 +769,7 @@ CAF_HAS_ALIAS_TRAIT(mapped_type);
// -- constexpr functions for use in enable_if & friends ----------------------- // -- constexpr functions for use in enable_if & friends -----------------------
/// Checks whether T behaves like a `std::map` or a `std::unordered_map`. /// Checks whether T behaves like `std::map`.
template <class T> template <class T>
struct is_map_like { struct is_map_like {
static constexpr bool value = is_iterable<T>::value static constexpr bool value = is_iterable<T>::value
...@@ -776,12 +777,11 @@ struct is_map_like { ...@@ -776,12 +777,11 @@ struct is_map_like {
&& has_mapped_type_alias<T>::value; && has_mapped_type_alias<T>::value;
}; };
/// Checks whether T behaves like a `std::vector` or a `std::list`. /// Checks whether T behaves like `std::vector`, `std::list`, or `std::set`.
template <class T> template <class T>
struct is_list_like { struct is_list_like {
static constexpr bool value = is_iterable<T>::value static constexpr bool value = is_iterable<T>::value
&& has_value_type_alias<T>::value && has_value_type_alias<T>::value
&& !has_key_type_alias<T>::value
&& !has_mapped_type_alias<T>::value; && !has_mapped_type_alias<T>::value;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment