diff --git a/unsupported/Eigen/CXX11/src/Core/util/CXX11Meta.h b/unsupported/Eigen/CXX11/src/Core/util/CXX11Meta.h index 7cd04a99e..7e4929ff8 100644 --- a/unsupported/Eigen/CXX11/src/Core/util/CXX11Meta.h +++ b/unsupported/Eigen/CXX11/src/Core/util/CXX11Meta.h @@ -252,6 +252,13 @@ template< typename... Ts > struct reduce; +template< + typename Reducer +> struct reduce +{ + constexpr static inline int run() { return Reducer::Identity; } +}; + template< typename Reducer, typename A, @@ -275,8 +282,14 @@ template< /* generic binary operations */ -struct sum_op { template constexpr static inline auto run(A a, B b) -> decltype(a + b) { return a + b; } }; -struct product_op { template constexpr static inline auto run(A a, B b) -> decltype(a * b) { return a * b; } }; +struct sum_op { + template constexpr static inline auto run(A a, B b) -> decltype(a + b) { return a + b; } + static constexpr int Identity = 0; +}; +struct product_op { + template constexpr static inline auto run(A a, B b) -> decltype(a * b) { return a * b; } + static constexpr int Identity = 1; +}; struct logical_and_op { template constexpr static inline auto run(A a, B b) -> decltype(a && b) { return a && b; } }; struct logical_or_op { template constexpr static inline auto run(A a, B b) -> decltype(a || b) { return a || b; } };