BOOST_MPL_HAS_XXX_TRAIT_DEF(iterator);
BOOST_MPL_HAS_XXX_TRAIT_DEF(mapped_type);
-template <typename T> struct class_is_container {
- typedef std::reverse_iterator<T*> some_iterator;
+template <typename T> struct iterator_class_is_container {
+ typedef std::reverse_iterator<typename T::iterator> some_iterator;
enum { value = has_value_type<T>::value &&
- has_iterator<T>::value &&
std::is_constructible<T, some_iterator, some_iterator>::value };
};
+template <typename T>
+using class_is_container = typename
+ std::conditional<
+ has_iterator<T>::value,
+ iterator_class_is_container<T>,
+ std::false_type
+ >::type;
+
template <typename T> struct class_is_range {
enum { value = has_value_type<T>::value &&
has_iterator<T>::value };
bool c1f = is_container<int>::value;
bool c2f = is_container<std::pair<int, int>>::value;
bool c3f = is_container<A>::value;
+ bool c4f = class_is_container<A>::value;
bool c1t = is_container<std::vector<int>>::value;
bool c2t = is_container<std::set<int>>::value;
bool c3t = is_container<std::map<int, int>>::value;
+ bool c4t = class_is_container<std::vector<A>>::value;
EXPECT_EQ(c1f, false);
EXPECT_EQ(c2f, false);
EXPECT_EQ(c3f, false);
+ EXPECT_EQ(c4f, false);
EXPECT_EQ(c1t, true);
EXPECT_EQ(c2t, true);
EXPECT_EQ(c3t, true);
+ EXPECT_EQ(c4t, true);
bool m1f = is_map<int>::value;