bug #1571: fix is_convertible<from,to> with "from" a reference.

This commit is contained in:
Gael Guennebaud 2018-07-13 17:47:28 +02:00
parent 1920129d71
commit 20991c3203
2 changed files with 10 additions and 2 deletions

View File

@ -161,7 +161,7 @@ private:
static no test(any_conversion, ...);
public:
static From* ms_from;
static typename internal::remove_reference<From>::type* ms_from;
#ifdef __INTEL_COMPILER
#pragma warning push
#pragma warning ( disable : 2259 )

View File

@ -80,7 +80,15 @@ void test_meta()
STATIC_CHECK(( internal::is_convertible<double,std::complex<double> >::value ));
STATIC_CHECK((!internal::is_convertible<std::complex<double>,double>::value ));
STATIC_CHECK(( internal::is_convertible<Array33f,Matrix3f>::value ));
// VERIFY((!internal::is_convertible<Matrix3f,Matrix3d>::value )); //does not work because the conversion is prevented by a static assertion
STATIC_CHECK(( internal::is_convertible<Matrix3f&,Matrix3f>::value ));
STATIC_CHECK(( internal::is_convertible<Matrix3f&,Matrix3f&>::value ));
STATIC_CHECK(( internal::is_convertible<Matrix3f&,const Matrix3f&>::value ));
STATIC_CHECK(( internal::is_convertible<const Matrix3f&,Matrix3f>::value ));
STATIC_CHECK(( internal::is_convertible<const Matrix3f&,const Matrix3f&>::value ));
STATIC_CHECK((!internal::is_convertible<const Matrix3f&,Matrix3f&>::value ));
STATIC_CHECK((!internal::is_convertible<const Matrix3f,Matrix3f&>::value ));
STATIC_CHECK(( internal::is_convertible<Matrix3f,Matrix3f&>::value )); // std::is_convertible returns false here though Matrix3f from; Matrix3f& to = from; is valid.
//STATIC_CHECK((!internal::is_convertible<Matrix3f,Matrix3d>::value )); //does not work because the conversion is prevented by a static assertion
STATIC_CHECK((!internal::is_convertible<Array33f,int>::value ));
STATIC_CHECK((!internal::is_convertible<MatrixXf,float>::value ));
{