// This file is part of Eigen, a lightweight C++ template library // for linear algebra. // // Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr> // // This Source Code Form is subject to the terms of the Mozilla // Public License v. 2.0. If a copy of the MPL was not distributed // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
//STATIC_CHECK((!internal::is_convertible<Matrix3f,Matrix3d>::value )); //does not even compile 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 ));
{ float f = 0.0f;
MatrixXf A, B;
VectorXf a, b;
VERIFY(( check_is_convertible(a.dot(b), f) ));
VERIFY(( check_is_convertible(a.transpose()*b, f) ));
VERIFY((!check_is_convertible(A*B, f) ));
VERIFY(( check_is_convertible(A*B, A) ));
}
#if (EIGEN_COMP_GNUC && EIGEN_COMP_GNUC <= 99) \
|| (EIGEN_COMP_CLANG && EIGEN_COMP_CLANG <= 909) \
|| (EIGEN_COMP_MSVC && EIGEN_COMP_MSVC <=1914) // See http://eigen.tuxfamily.org/bz/show_bug.cgi?id=1752, // basically, a fix in the c++ standard breaks our c++98 implementation // of is_convertible for abstract classes. // So the following tests are expected to fail with recent compilers.
STATIC_CHECK(( !internal::is_convertible<MyInterface, MyImpl>::value )); #if (!EIGEN_COMP_GNUC_STRICT) || (EIGEN_GNUC_AT_LEAST(4,8)) // GCC prior to 4.8 fails to compile this test: // error: cannot allocate an object of abstract type 'MyInterface' // In other word, it does not obey SFINAE. // Nevertheless, we don't really care about supporting abstract type as scalar type!
STATIC_CHECK(( !internal::is_convertible<MyImpl, MyInterface>::value )); #endif
STATIC_CHECK(( internal::is_convertible<MyImpl, const MyInterface&>::value ));
#endif
{ int i = 0;
VERIFY(( check_is_convertible(fix<3>(), i) ));
VERIFY((!check_is_convertible(i, fix<DynamicIndex>()) ));
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.