Commit 6a2eb674 authored by 191919's avatar 191919 Committed by Sara Golemon

Fix for clang (llvm 3.7.0+)

Summary: Roughly described in https://github.com/facebook/hhvm/issues/5344.

Closes #206

Reviewed By: @yfeldblum

Differential Revision: D2170803

Pulled By: @sgolemon
parent 01d31b9f
...@@ -54,13 +54,20 @@ BOOST_MPL_HAS_XXX_TRAIT_DEF(value_type); ...@@ -54,13 +54,20 @@ BOOST_MPL_HAS_XXX_TRAIT_DEF(value_type);
BOOST_MPL_HAS_XXX_TRAIT_DEF(iterator); BOOST_MPL_HAS_XXX_TRAIT_DEF(iterator);
BOOST_MPL_HAS_XXX_TRAIT_DEF(mapped_type); BOOST_MPL_HAS_XXX_TRAIT_DEF(mapped_type);
template <typename T> struct class_is_container { template <typename T> struct iterator_class_is_container {
typedef std::reverse_iterator<T*> some_iterator; typedef std::reverse_iterator<typename T::iterator> some_iterator;
enum { value = has_value_type<T>::value && enum { value = has_value_type<T>::value &&
has_iterator<T>::value &&
std::is_constructible<T, some_iterator, some_iterator>::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 { template <typename T> struct class_is_range {
enum { value = has_value_type<T>::value && enum { value = has_value_type<T>::value &&
has_iterator<T>::value }; has_iterator<T>::value };
......
...@@ -35,17 +35,21 @@ TEST(DynamicConverter, template_metaprogramming) { ...@@ -35,17 +35,21 @@ TEST(DynamicConverter, template_metaprogramming) {
bool c1f = is_container<int>::value; bool c1f = is_container<int>::value;
bool c2f = is_container<std::pair<int, int>>::value; bool c2f = is_container<std::pair<int, int>>::value;
bool c3f = is_container<A>::value; bool c3f = is_container<A>::value;
bool c4f = class_is_container<A>::value;
bool c1t = is_container<std::vector<int>>::value; bool c1t = is_container<std::vector<int>>::value;
bool c2t = is_container<std::set<int>>::value; bool c2t = is_container<std::set<int>>::value;
bool c3t = is_container<std::map<int, 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(c1f, false);
EXPECT_EQ(c2f, false); EXPECT_EQ(c2f, false);
EXPECT_EQ(c3f, false); EXPECT_EQ(c3f, false);
EXPECT_EQ(c4f, false);
EXPECT_EQ(c1t, true); EXPECT_EQ(c1t, true);
EXPECT_EQ(c2t, true); EXPECT_EQ(c2t, true);
EXPECT_EQ(c3t, true); EXPECT_EQ(c3t, true);
EXPECT_EQ(c4t, true);
bool m1f = is_map<int>::value; bool m1f = is_map<int>::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