From e9ecfad7967fd5285846647372897ecdc125f976 Mon Sep 17 00:00:00 2001 From: Benoit Steiner Date: Thu, 12 Nov 2015 16:41:14 -0800 Subject: [PATCH] Started to make the IndexList code compile by more compilers --- .../CXX11/src/Tensor/TensorDimensionList.h | 16 +++++----- .../Eigen/CXX11/src/Tensor/TensorIndexList.h | 30 +++++++++++-------- .../Eigen/CXX11/src/Tensor/TensorReduction.h | 8 ++--- 3 files changed, 29 insertions(+), 25 deletions(-) diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorDimensionList.h b/unsupported/Eigen/CXX11/src/Tensor/TensorDimensionList.h index 17d89d5e1..da7782188 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorDimensionList.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorDimensionList.h @@ -72,14 +72,14 @@ struct all_indices_known_statically > { }; template -struct indices_statically_known_to_increase > { - constexpr bool operator() () const { +struct indices_statically_known_to_increase_impl > { + static constexpr bool run() { return true; } }; template -struct indices_statically_known_to_increase > { - constexpr bool operator() () const { +struct indices_statically_known_to_increase_impl > { + static constexpr bool run() { return true; } }; @@ -164,14 +164,14 @@ struct all_indices_known_statically > { }; template -struct indices_statically_known_to_increase > { - EIGEN_ALWAYS_INLINE bool operator() () const { +struct indices_statically_known_to_increase_impl > { + static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool run() { return true; } }; template -struct indices_statically_known_to_increase > { - EIGEN_ALWAYS_INLINE bool operator() () const { +struct indices_statically_known_to_increase_impl > { + static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool run() { return true; } }; diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorIndexList.h b/unsupported/Eigen/CXX11/src/Tensor/TensorIndexList.h index dcd2464f1..69d21d3c1 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorIndexList.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorIndexList.h @@ -336,26 +336,32 @@ struct all_indices_known_statically > }; template -struct indices_statically_known_to_increase { - constexpr bool operator() () const { +struct indices_statically_known_to_increase_impl { + static constexpr bool run() { return false; } }; template -struct indices_statically_known_to_increase > { - constexpr bool operator() () const { - return IndexList().values_statically_known_to_increase(); + struct indices_statically_known_to_increase_impl > { + static constexpr bool run() { + return Eigen::IndexList().values_statically_known_to_increase(); } }; template -struct indices_statically_known_to_increase > { - constexpr bool operator() () const { - return IndexList().values_statically_known_to_increase(); + struct indices_statically_known_to_increase_impl > { + static constexpr bool run() { + return Eigen::IndexList().values_statically_known_to_increase(); } }; +template +static constexpr bool indices_statically_known_to_increase() { + return indices_statically_known_to_increase_impl::run(); +} + + template struct index_statically_eq { constexpr bool operator() (DenseIndex, DenseIndex) const { @@ -473,11 +479,9 @@ struct all_indices_known_statically { }; template -struct indices_statically_known_to_increase { - EIGEN_ALWAYS_INLINE EIGEN_DEVICE_FUNC bool operator() () const { - return false; - } -}; +static EIGEN_ALWAYS_INLINE EIGEN_DEVICE_FUNC bool indices_statically_known_to_increase() { + return false; +} template struct index_statically_eq { diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h index c1cdb98a4..4d3e25d87 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h @@ -88,14 +88,14 @@ struct preserve_inner_most_dims { #if defined(EIGEN_HAS_CONSTEXPR) && defined(EIGEN_HAS_VARIADIC_TEMPLATES) template struct are_inner_most_dims{ - static const bool tmp1 = indices_statically_known_to_increase()(); + static const bool tmp1 = indices_statically_known_to_increase(); static const bool tmp2 = index_statically_eq()(0, 0); static const bool tmp3 = index_statically_eq()(array_size::value-1, array_size::value-1); static const bool value = tmp1 & tmp2 & tmp3; }; template struct are_inner_most_dims{ - static const bool tmp1 = indices_statically_known_to_increase()(); + static const bool tmp1 = indices_statically_known_to_increase(); static const bool tmp2 = index_statically_eq()(0, NumTensorDims - array_size::value); static const bool tmp3 = index_statically_eq()(array_size::value - 1, NumTensorDims - 1); static const bool value = tmp1 & tmp2 & tmp3; @@ -103,14 +103,14 @@ struct are_inner_most_dims{ }; template struct preserve_inner_most_dims{ - static const bool tmp1 = indices_statically_known_to_increase()(); + static const bool tmp1 = indices_statically_known_to_increase(); static const bool tmp2 = index_statically_gt()(0, 0); static const bool value = tmp1 & tmp2; }; template struct preserve_inner_most_dims{ - static const bool tmp1 = indices_statically_known_to_increase()(); + static const bool tmp1 = indices_statically_known_to_increase(); static const bool tmp2 = index_statically_lt()(array_size::value - 1, NumTensorDims - 1); static const bool value = tmp1 & tmp2; };