diff options
author | Benoit Steiner <benoit.steiner.goog@gmail.com> | 2017-02-10 13:08:49 -0800 |
---|---|---|
committer | Benoit Steiner <benoit.steiner.goog@gmail.com> | 2017-02-10 13:08:49 -0800 |
commit | 8b3cc54c42d6f2cc7db6f2a56da0e6510782b747 (patch) | |
tree | 96f56f49a34f7b848d4e053600ac46b5a45fe314 | |
parent | a1ff24f96a1280cd7d7395f739d8f265150879bb (diff) |
Added a new EIGEN_HAS_INDEXED_VIEW define that set to 0 for older compilers that are known to fail to compile the indexed views (I used the define from the indexed_views.cpp test).
Only include the indexed view methods when the compiler supports the code.
This makes it possible to use Eigen again in complex code bases such as TensorFlow and older compilers such as gcc 4.8
-rw-r--r-- | Eigen/src/Core/util/Macros.h | 6 | ||||
-rw-r--r-- | Eigen/src/plugins/IndexedViewMethods.h | 5 | ||||
-rw-r--r-- | test/indexed_view.cpp | 4 |
3 files changed, 10 insertions, 5 deletions
diff --git a/Eigen/src/Core/util/Macros.h b/Eigen/src/Core/util/Macros.h index bc033959c..0e2863306 100644 --- a/Eigen/src/Core/util/Macros.h +++ b/Eigen/src/Core/util/Macros.h @@ -349,6 +349,12 @@ # define __has_feature(x) 0 #endif +#if !( EIGEN_COMP_CLANG && ((EIGEN_COMP_CLANG<309) || defined(__apple_build_version__)) || EIGEN_COMP_GNUC_STRICT && EIGEN_COMP_GNUC<49) +#define EIGEN_HAS_INDEXED_VIEW 1 +#else +#define EIGEN_HAS_INDEXED_VIEW 0 +#endif + // Upperbound on the C++ version to use. // Expected values are 03, 11, 14, 17, etc. // By default, let's use an arbitrarily large C++ version. diff --git a/Eigen/src/plugins/IndexedViewMethods.h b/Eigen/src/plugins/IndexedViewMethods.h index b2cc2944a..5e28ec71c 100644 --- a/Eigen/src/plugins/IndexedViewMethods.h +++ b/Eigen/src/plugins/IndexedViewMethods.h @@ -7,7 +7,7 @@ // 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/. -#ifndef EIGEN_PARSED_BY_DOXYGEN +#if !defined(EIGEN_PARSED_BY_DOXYGEN) && EIGEN_HAS_INDEXED_VIEW // This file is automatically included twice to generate const and non-const versions @@ -256,5 +256,4 @@ template<typename Indices> IndexedView_or_VectorBlock operator()(const Indices& indices); -#endif // EIGEN_PARSED_BY_DOXYGEN - +#endif // EIGEN_PARSED_BY_DOXYGEN && EIGEN_HAS_INDEXED_VIEW diff --git a/test/indexed_view.cpp b/test/indexed_view.cpp index 86342dc0a..4cbc00639 100644 --- a/test/indexed_view.cpp +++ b/test/indexed_view.cpp @@ -79,6 +79,7 @@ is_same_seq_type(const T1& a, const T2& b) void check_indexed_view() { +#if EIGEN_HAS_INDEXED_VIEW using Eigen::placeholders::all; using Eigen::placeholders::last; using Eigen::placeholders::end; @@ -297,7 +298,6 @@ void check_indexed_view() VERIFY_IS_APPROX( (A(std::array<int,3>{{1,3,5}}, std::array<int,4>{{9,6,3,0}})), A(seqN(1,3,2), seqN(9,4,-3)) ); -#if !( EIGEN_COMP_CLANG && ((EIGEN_COMP_CLANG<309) || defined(__apple_build_version__)) || EIGEN_COMP_GNUC_STRICT && EIGEN_COMP_GNUC<49) VERIFY_IS_APPROX( A({3, 1, 6, 5}, all), A(std::array<int,4>{{3, 1, 6, 5}}, all) ); VERIFY_IS_APPROX( A(all,{3, 1, 6, 5}), A(all,std::array<int,4>{{3, 1, 6, 5}}) ); VERIFY_IS_APPROX( A({1,3,5},{3, 1, 6, 5}), A(std::array<int,3>{{1,3,5}},std::array<int,4>{{3, 1, 6, 5}}) ); @@ -310,7 +310,6 @@ void check_indexed_view() VERIFY_IS_APPROX( b({3, 1, 6, 5}), b(std::array<int,4>{{3, 1, 6, 5}}) ); VERIFY_IS_EQUAL( b({1,3,5}).SizeAtCompileTime, 3 ); -#endif #endif @@ -366,6 +365,7 @@ void check_indexed_view() VERIFY( is_same_eq( cA.middleRows<3>(1), cA.middleRows(1,fix<3>)) ); } +#endif // EIGEN_HAS_INDEXED_VIEW } void test_indexed_view() |