mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-01-24 14:45:14 +08:00
Protect c++11 type alias with Eigen's macro, and add respective unit test.
This commit is contained in:
parent
7195f008ce
commit
44b54fa4a3
@ -350,7 +350,7 @@ EIGEN_MAKE_ARRAY_TYPEDEFS_ALL_SIZES(std::complex<double>, cd)
|
||||
#undef EIGEN_MAKE_ARRAY_TYPEDEFS_ALL_SIZES
|
||||
#undef EIGEN_MAKE_ARRAY_TYPEDEFS
|
||||
|
||||
#if __cplusplus>=201103L
|
||||
#if EIGEN_HAS_CXX11
|
||||
|
||||
#define EIGEN_MAKE_TYPEDEFS(Size, SizeSuffix) \
|
||||
/** \ingroup matrixtypedefs */ \
|
||||
@ -379,7 +379,7 @@ EIGEN_MAKE_FIXED_TYPEDEFS(4)
|
||||
#undef EIGEN_MAKE_TYPEDEFS
|
||||
#undef EIGEN_MAKE_FIXED_TYPEDEFS
|
||||
|
||||
#endif // __cplusplus>=201103L
|
||||
#endif // EIGEN_HAS_CXX11
|
||||
|
||||
#define EIGEN_USING_ARRAY_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, SizeSuffix) \
|
||||
using Eigen::Matrix##SizeSuffix##TypeSuffix; \
|
||||
|
@ -499,7 +499,7 @@ EIGEN_MAKE_TYPEDEFS_ALL_SIZES(std::complex<double>, cd)
|
||||
#undef EIGEN_MAKE_TYPEDEFS
|
||||
#undef EIGEN_MAKE_FIXED_TYPEDEFS
|
||||
|
||||
#if __cplusplus>=201103L
|
||||
#if EIGEN_HAS_CXX11
|
||||
|
||||
#define EIGEN_MAKE_TYPEDEFS(Size, SizeSuffix) \
|
||||
/** \ingroup matrixtypedefs */ \
|
||||
@ -531,7 +531,7 @@ EIGEN_MAKE_FIXED_TYPEDEFS(4)
|
||||
#undef EIGEN_MAKE_TYPEDEFS
|
||||
#undef EIGEN_MAKE_FIXED_TYPEDEFS
|
||||
|
||||
#endif // __cplusplus>=201103L
|
||||
#endif // EIGEN_HAS_CXX11
|
||||
|
||||
} // end namespace Eigen
|
||||
|
||||
|
@ -164,6 +164,7 @@ ei_add_test(sizeof)
|
||||
ei_add_test(dynalloc)
|
||||
ei_add_test(nomalloc)
|
||||
ei_add_test(first_aligned)
|
||||
ei_add_test(type_alias)
|
||||
ei_add_test(nullary)
|
||||
ei_add_test(mixingtypes)
|
||||
ei_add_test(packetmath "-DEIGEN_FAST_MATH=1")
|
||||
|
43
test/type_alias.cpp
Normal file
43
test/type_alias.cpp
Normal file
@ -0,0 +1,43 @@
|
||||
// This file is part of Eigen, a lightweight C++ template library
|
||||
// for linear algebra.
|
||||
//
|
||||
// Copyright (C) 2019 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/.
|
||||
|
||||
#include "main.h"
|
||||
|
||||
EIGEN_DECLARE_TEST(type_alias)
|
||||
{
|
||||
using namespace internal;
|
||||
|
||||
// To warm up, some basic checks:
|
||||
STATIC_CHECK((is_same<MatrixXd,Matrix<double,Dynamic,Dynamic> >::value));
|
||||
STATIC_CHECK((is_same<Matrix2f,Matrix<float,2,2> >::value));
|
||||
STATIC_CHECK((is_same<Array33i,Array<int,3,3> >::value));
|
||||
|
||||
#if EIGEN_HAS_CXX11
|
||||
|
||||
STATIC_CHECK((is_same<MatrixX<double>, MatrixXd>::value));
|
||||
STATIC_CHECK((is_same<MatrixX<int>, MatrixXi>::value));
|
||||
STATIC_CHECK((is_same<Matrix2<int>, Matrix2i>::value));
|
||||
STATIC_CHECK((is_same<Matrix2X<float>, Matrix2Xf>::value));
|
||||
STATIC_CHECK((is_same<MatrixX4<double>, MatrixX4d>::value));
|
||||
STATIC_CHECK((is_same<VectorX<int>, VectorXi>::value));
|
||||
STATIC_CHECK((is_same<Vector2<float>, Vector2f>::value));
|
||||
STATIC_CHECK((is_same<RowVectorX<int>, RowVectorXi>::value));
|
||||
STATIC_CHECK((is_same<RowVector2<float>, RowVector2f>::value));
|
||||
|
||||
STATIC_CHECK((is_same<ArrayXX<float>, ArrayXXf>::value));
|
||||
STATIC_CHECK((is_same<Array33<int>, Array33i>::value));
|
||||
STATIC_CHECK((is_same<Array2X<float>, Array2Xf>::value));
|
||||
STATIC_CHECK((is_same<ArrayX4<double>, ArrayX4d>::value));
|
||||
STATIC_CHECK((is_same<ArrayX<double>, ArrayXd>::value));
|
||||
STATIC_CHECK((is_same<Array4<double>, Array4d>::value));
|
||||
|
||||
#else
|
||||
std::cerr << "WARNING: c++11 type aliases not tested.\n";
|
||||
#endif
|
||||
}
|
Loading…
Reference in New Issue
Block a user