diff options
author | 2014-07-18 11:02:22 +0200 | |
---|---|---|
committer | 2014-07-18 11:02:22 +0200 | |
commit | a325d1cb1e607c36d602b1cad9a57b05c60050fa (patch) | |
tree | 0c4576947946af90cb8587a4ccbf7030c5b8f772 /Eigen/src/Core/util/Meta.h | |
parent | 2bdb3b1afdbc07d54fec43edff92138f82492941 (diff) | |
parent | da62eb22e497d864ccaed93907818a384bad8e2a (diff) |
merge with default branch
Diffstat (limited to 'Eigen/src/Core/util/Meta.h')
-rw-r--r-- | Eigen/src/Core/util/Meta.h | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/Eigen/src/Core/util/Meta.h b/Eigen/src/Core/util/Meta.h index c578b6c86..f3bafd5af 100644 --- a/Eigen/src/Core/util/Meta.h +++ b/Eigen/src/Core/util/Meta.h @@ -82,22 +82,31 @@ template<typename T> struct add_const_on_value_type<T const* const> { typedef T template<typename From, typename To> -struct is_convertible +struct is_convertible_impl { private: + struct any_conversion + { + template <typename T> any_conversion(const volatile T&); + template <typename T> any_conversion(T&); + }; struct yes {int a[1];}; struct no {int a[2];}; - - template<typename T> - static yes test (const T&) {} - - template<typename> static no test (...) {} + + static yes test(const To&, int); + static no test(any_conversion, ...); public: static From ms_from; - enum { value = sizeof(test<To>(ms_from))==sizeof(yes) }; + enum { value = sizeof(test(ms_from, 0))==sizeof(yes) }; }; +template<typename From, typename To> +struct is_convertible +{ + enum { value = is_convertible_impl<typename remove_all<From>::type, + typename remove_all<To >::type>::value }; +}; /** \internal Allows to enable/disable an overload * according to a compile time condition. |