diff --git a/Eigen/src/Core/util/Meta.h b/Eigen/src/Core/util/Meta.h index ef9860c4b..3d2bdd12e 100755 --- a/Eigen/src/Core/util/Meta.h +++ b/Eigen/src/Core/util/Meta.h @@ -145,16 +145,19 @@ private: struct yes {int a[1];}; struct no {int a[2];}; - static yes test(const To&, int); + template + static yes test(T, int); + + template static no test(any_conversion, ...); public: - static From ms_from; + static From* ms_from; #ifdef __INTEL_COMPILER #pragma warning push #pragma warning ( disable : 2259 ) #endif - enum { value = sizeof(test(ms_from, 0))==sizeof(yes) }; + enum { value = sizeof(test(*ms_from, 0))==sizeof(yes) }; #ifdef __INTEL_COMPILER #pragma warning pop #endif @@ -163,8 +166,7 @@ public: template struct is_convertible { - enum { value = is_convertible_impl::type, - typename remove_all::type>::value }; + enum { value = is_convertible_impl::value }; }; /** \internal Allows to enable/disable an overload diff --git a/test/meta.cpp b/test/meta.cpp index bd505762e..4904f3ba4 100644 --- a/test/meta.cpp +++ b/test/meta.cpp @@ -19,6 +19,14 @@ struct FooReturnType { typedef int ReturnType; }; +struct MyInterface { + virtual void func() = 0; + virtual ~MyInterface() {} +}; +struct MyImpl : public MyInterface { + void func() {} +}; + void test_meta() { VERIFY((internal::conditional<(3<4),internal::true_type, internal::false_type>::type::value)); @@ -62,14 +70,19 @@ void test_meta() VERIFY(( internal::is_same::type >::value)); VERIFY(( internal::is_same::type >::value)); - VERIFY(( internal::is_convertible::value )); - VERIFY(( internal::is_convertible::value )); - VERIFY(( internal::is_convertible::value )); - VERIFY((!internal::is_convertible,double>::value )); - VERIFY(( internal::is_convertible::value )); + + // is_convertible + STATIC_CHECK(( internal::is_convertible::value )); + STATIC_CHECK(( internal::is_convertible::value )); + STATIC_CHECK(( internal::is_convertible::value )); + STATIC_CHECK(( internal::is_convertible::value )); + STATIC_CHECK(( internal::is_convertible::value )); + STATIC_CHECK(( internal::is_convertible >::value )); + STATIC_CHECK((!internal::is_convertible,double>::value )); + STATIC_CHECK(( internal::is_convertible::value )); // VERIFY((!internal::is_convertible::value )); //does not work because the conversion is prevented by a static assertion - VERIFY((!internal::is_convertible::value )); - VERIFY((!internal::is_convertible::value )); + STATIC_CHECK((!internal::is_convertible::value )); + STATIC_CHECK((!internal::is_convertible::value )); { float f; MatrixXf A, B; @@ -80,6 +93,15 @@ void test_meta() VERIFY(( check_is_convertible(A*B, A) )); } + STATIC_CHECK(( !internal::is_convertible::value )); + STATIC_CHECK(( !internal::is_convertible::value )); + STATIC_CHECK(( internal::is_convertible::value )); + { + int i; + VERIFY(( check_is_convertible(fix<3>(), i) )); + VERIFY((!check_is_convertible(i, fix()) )); + } + VERIFY(( internal::has_ReturnType::value )); VERIFY(( internal::has_ReturnType >::value )); VERIFY(( !internal::has_ReturnType::value ));