aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2019-02-20 14:43:05 +0100
committerGravatar Gael Guennebaud <g.gael@free.fr>2019-02-20 14:43:05 +0100
commit44b54fa4a3618922e06abdca9c555b8697698237 (patch)
tree3d61d55a0d8bfd4d289eea0558d8636bfc834fec
parent7195f008ced2ec7fc8a1926d06b7cd797e9f3642 (diff)
Protect c++11 type alias with Eigen's macro, and add respective unit test.
-rw-r--r--Eigen/src/Core/Array.h4
-rw-r--r--Eigen/src/Core/Matrix.h4
-rw-r--r--test/CMakeLists.txt1
-rw-r--r--test/type_alias.cpp43
4 files changed, 48 insertions, 4 deletions
diff --git a/Eigen/src/Core/Array.h b/Eigen/src/Core/Array.h
index 039f41a3d..a85d5084b 100644
--- a/Eigen/src/Core/Array.h
+++ b/Eigen/src/Core/Array.h
@@ -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; \
diff --git a/Eigen/src/Core/Matrix.h b/Eigen/src/Core/Matrix.h
index ea5f7da78..83cffc8e6 100644
--- a/Eigen/src/Core/Matrix.h
+++ b/Eigen/src/Core/Matrix.h
@@ -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
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 3dbb426eb..f74e22c28 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -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")
diff --git a/test/type_alias.cpp b/test/type_alias.cpp
new file mode 100644
index 000000000..f9b0efc5d
--- /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
+}