Protect c++11 type alias with Eigen's macro, and add respective unit test.
diff --git a/Eigen/src/Core/Array.h b/Eigen/src/Core/Array.h index 039f41a..a85d508 100644 --- a/Eigen/src/Core/Array.h +++ b/Eigen/src/Core/Array.h
@@ -350,7 +350,7 @@ #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 @@ #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; \
diff --git a/Eigen/src/Core/Matrix.h b/Eigen/src/Core/Matrix.h index ea5f7da..83cffc8 100644 --- a/Eigen/src/Core/Matrix.h +++ b/Eigen/src/Core/Matrix.h
@@ -499,7 +499,7 @@ #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 @@ #undef EIGEN_MAKE_TYPEDEFS #undef EIGEN_MAKE_FIXED_TYPEDEFS -#endif // __cplusplus>=201103L +#endif // EIGEN_HAS_CXX11 } // end namespace Eigen
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 3dbb426..f74e22c 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt
@@ -164,6 +164,7 @@ 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")
diff --git a/test/type_alias.cpp b/test/type_alias.cpp new file mode 100644 index 0000000..f9b0efc --- /dev/null +++ b/test/type_alias.cpp
@@ -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 +}