From 338d2ec42b99a17f4fa1759f27bf8735b4aea974 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Wed, 16 Jul 2014 13:17:06 +0200 Subject: bug #826: fix is_convertible for MSVC and add minimalistic unit test for is_convertible --- Eigen/src/Core/util/Meta.h | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'Eigen/src/Core/util/Meta.h') diff --git a/Eigen/src/Core/util/Meta.h b/Eigen/src/Core/util/Meta.h index 795197f59..b99b8849e 100644 --- a/Eigen/src/Core/util/Meta.h +++ b/Eigen/src/Core/util/Meta.h @@ -82,22 +82,31 @@ template struct add_const_on_value_type { typedef T template -struct is_convertible +struct is_convertible_impl { private: + struct any_conversion + { + template any_conversion(const volatile T&); + template any_conversion(T&); + }; struct yes {int a[1];}; struct no {int a[2];}; - - template - static yes test (const T&) {} - - template static no test (...) {} + + static yes test(const To&, int); + static no test(any_conversion, ...); public: static From ms_from; - enum { value = sizeof(test(ms_from))==sizeof(yes) }; + enum { value = sizeof(test(ms_from, 0))==sizeof(yes) }; }; +template +struct is_convertible +{ + enum { value = is_convertible_impl::type, + typename remove_all::type>::value }; +}; /** \internal Allows to enable/disable an overload * according to a compile time condition. -- cgit v1.2.3