From f36538049669a7efee57f2b1e3c60bf8bf3976bb Mon Sep 17 00:00:00 2001 From: Christoph Hertzberg Date: Fri, 4 Jul 2014 12:52:55 +0200 Subject: [PATCH] Fix regression introduced by 3117036b80075390dbc46f60aa0d595e5a44661b : Matrix(int) did not compile if Scalar is not constructible from int. Now this falls back to the (Index size) constructor. --- Eigen/src/Core/PlainObjectBase.h | 4 ++-- Eigen/src/Core/util/Meta.h | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/Eigen/src/Core/PlainObjectBase.h b/Eigen/src/Core/PlainObjectBase.h index b5b25ef70c..ae5b342cea 100644 --- a/Eigen/src/Core/PlainObjectBase.h +++ b/Eigen/src/Core/PlainObjectBase.h @@ -692,7 +692,7 @@ class PlainObjectBase : public internal::dense_xpr_base::type template EIGEN_DEVICE_FUNC - EIGEN_STRONG_INLINE void _init1(Index size, typename internal::enable_if::type* = 0) + EIGEN_STRONG_INLINE void _init1(Index size, typename internal::enable_if::value,T>::type* = 0) { EIGEN_STATIC_ASSERT(bool(NumTraits::IsInteger), FLOATING_POINT_ARGUMENT_PASSED__INTEGER_WAS_EXPECTED) @@ -700,7 +700,7 @@ class PlainObjectBase : public internal::dense_xpr_base::type } template EIGEN_DEVICE_FUNC - EIGEN_STRONG_INLINE void _init1(const Scalar& val0, typename internal::enable_if::type* = 0) + EIGEN_STRONG_INLINE void _init1(const Scalar& val0, typename internal::enable_if::value,T>::type* = 0) { EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(PlainObjectBase, 1) m_storage.data()[0] = val0; diff --git a/Eigen/src/Core/util/Meta.h b/Eigen/src/Core/util/Meta.h index e4e4d4a87e..795197f594 100644 --- a/Eigen/src/Core/util/Meta.h +++ b/Eigen/src/Core/util/Meta.h @@ -80,6 +80,25 @@ template struct add_const_on_value_type { typedef T const template struct add_const_on_value_type { typedef T const* const type; }; template struct add_const_on_value_type { typedef T const* const type; }; + +template +struct is_convertible +{ +private: + struct yes {int a[1];}; + struct no {int a[2];}; + + template + static yes test (const T&) {} + + template static no test (...) {} + +public: + static From ms_from; + enum { value = sizeof(test(ms_from))==sizeof(yes) }; +}; + + /** \internal Allows to enable/disable an overload * according to a compile time condition. */