From 0f4dd15dfc6e18e88cc55f561cf4ee2a772ab350 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Thu, 19 Feb 2015 23:28:57 +0100 Subject: [PATCH 1/4] Declare const some const variables --- Eigen/src/Core/GeneralProduct.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Eigen/src/Core/GeneralProduct.h b/Eigen/src/Core/GeneralProduct.h index 7027130e0..0ecfab449 100644 --- a/Eigen/src/Core/GeneralProduct.h +++ b/Eigen/src/Core/GeneralProduct.h @@ -249,8 +249,8 @@ template<> struct gemv_dense_sense_selector gemv_static_vector_if static_dest; - bool alphaIsCompatible = (!ComplexByReal) || (numext::imag(actualAlpha)==RealScalar(0)); - bool evalToDest = EvalToDestAtCompileTime && alphaIsCompatible; + const bool alphaIsCompatible = (!ComplexByReal) || (numext::imag(actualAlpha)==RealScalar(0)); + const bool evalToDest = EvalToDestAtCompileTime && alphaIsCompatible; RhsScalar compatibleAlpha = get_factor::run(actualAlpha); From 1b7e12847d099ab6715c3ee99f068c9fd19858fc Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Thu, 19 Feb 2015 23:30:41 +0100 Subject: [PATCH 2/4] Fix some calls to result_of on binary functors as unary ones. --- Eigen/src/Core/DenseBase.h | 2 +- Eigen/src/Core/Redux.h | 2 +- Eigen/src/Core/VectorwiseOp.h | 2 +- Eigen/src/Geometry/Homogeneous.h | 2 +- test/array.cpp | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Eigen/src/Core/DenseBase.h b/Eigen/src/Core/DenseBase.h index 322daad8f..c30d1bed9 100644 --- a/Eigen/src/Core/DenseBase.h +++ b/Eigen/src/Core/DenseBase.h @@ -429,7 +429,7 @@ template class DenseBase template EIGEN_DEVICE_FUNC - typename internal::result_of::Scalar)>::type + typename internal::result_of::Scalar,typename internal::traits::Scalar)>::type redux(const BinaryOp& func) const; template diff --git a/Eigen/src/Core/Redux.h b/Eigen/src/Core/Redux.h index 1a0a00481..f704fd07b 100644 --- a/Eigen/src/Core/Redux.h +++ b/Eigen/src/Core/Redux.h @@ -406,7 +406,7 @@ protected: */ template template -EIGEN_STRONG_INLINE typename internal::result_of::Scalar)>::type +EIGEN_STRONG_INLINE typename internal::result_of::Scalar,typename internal::traits::Scalar)>::type DenseBase::redux(const Func& func) const { eigen_assert(this->rows()>0 && this->cols()>0 && "you are using an empty matrix"); diff --git a/Eigen/src/Core/VectorwiseOp.h b/Eigen/src/Core/VectorwiseOp.h index b3dc0c224..a15777a5e 100644 --- a/Eigen/src/Core/VectorwiseOp.h +++ b/Eigen/src/Core/VectorwiseOp.h @@ -124,7 +124,7 @@ EIGEN_MEMBER_FUNCTOR(prod, (Size-1)*NumTraits::MulCost); template struct member_redux { typedef typename result_of< - BinaryOp(Scalar) + BinaryOp(Scalar,Scalar) >::type result_type; template struct Cost { enum { value = (Size-1) * functor_traits::Cost }; }; diff --git a/Eigen/src/Geometry/Homogeneous.h b/Eigen/src/Geometry/Homogeneous.h index f16451656..756ecf9dc 100644 --- a/Eigen/src/Geometry/Homogeneous.h +++ b/Eigen/src/Geometry/Homogeneous.h @@ -102,7 +102,7 @@ template class Homogeneous } template - EIGEN_STRONG_INLINE typename internal::result_of::type + EIGEN_STRONG_INLINE typename internal::result_of::type redux(const Func& func) const { return func(m_matrix.redux(func), Scalar(1)); diff --git a/test/array.cpp b/test/array.cpp index ac9be097d..ad0182e10 100644 --- a/test/array.cpp +++ b/test/array.cpp @@ -331,7 +331,7 @@ void test_array() VERIFY((internal::is_same< internal::global_math_functions_filtering_base::type, int >::value)); VERIFY((internal::is_same< internal::global_math_functions_filtering_base::type, float >::value)); VERIFY((internal::is_same< internal::global_math_functions_filtering_base::type, ArrayBase >::value)); - typedef CwiseUnaryOp, ArrayXd > Xpr; + typedef CwiseUnaryOp, ArrayXd > Xpr; VERIFY((internal::is_same< internal::global_math_functions_filtering_base::type, ArrayBase >::value)); From ece6b440f969c129afbc5e5aaa966ce1df6f78e2 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Thu, 19 Feb 2015 23:31:08 +0100 Subject: [PATCH 3/4] Fix a C++11 compilation issue in unit test --- test/sparse_solver.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/sparse_solver.h b/test/sparse_solver.h index 892a9777f..f0a4691e3 100644 --- a/test/sparse_solver.h +++ b/test/sparse_solver.h @@ -145,7 +145,7 @@ void check_sparse_solving_real_cases(Solver& solver, const typename Solver::Matr res_error = (b - A * x).norm()/b.norm(); } if (res_error > test_precision() ){ - std::cerr << "Test " << g_test_stack.back() << " failed in "EI_PP_MAKE_STRING(__FILE__) + std::cerr << "Test " << g_test_stack.back() << " failed in " EI_PP_MAKE_STRING(__FILE__) << " (" << EI_PP_MAKE_STRING(__LINE__) << ")" << std::endl << std::endl; abort(); } From a66f5fc2fd5ae26eeecb327e4bde9aeaa0edfced Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Thu, 19 Feb 2015 23:32:12 +0100 Subject: [PATCH 4/4] Fix regression with C++11 support of lambda: now internal::result_of falls back to std::result_of in C++11. --- Eigen/src/Core/util/Meta.h | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/Eigen/src/Core/util/Meta.h b/Eigen/src/Core/util/Meta.h index 674cd8f97..974f11516 100644 --- a/Eigen/src/Core/util/Meta.h +++ b/Eigen/src/Core/util/Meta.h @@ -160,12 +160,17 @@ protected: * upcoming next STL generation (using a templated result member). * If none of these members is provided, then the type of the first argument is returned. FIXME, that behavior is a pretty bad hack. */ -template struct result_of {}; +#ifdef EIGEN_HAS_STD_RESULT_OF +template struct result_of { + typedef typename std::result_of::type type1; + typedef typename remove_all::type type; +}; +#else +template struct result_of { }; struct has_none {int a[1];}; struct has_std_result_type {int a[2];}; struct has_tr1_result {int a[3];}; -struct has_cxx_eleven_result {int a[4];}; template struct unary_result_of_select {typedef ArgType type;}; @@ -176,21 +181,12 @@ struct unary_result_of_select {typed template struct unary_result_of_select {typedef typename Func::template result::type type;}; -#ifdef EIGEN_HAS_STD_RESULT_OF -template -struct unary_result_of_select {typedef typename std::result_of::type type;}; -#endif - template struct result_of { template static has_std_result_type testFunctor(T const *, typename T::result_type const * = 0); template static has_tr1_result testFunctor(T const *, typename T::template result::type const * = 0); -#ifdef EIGEN_HAS_STD_RESULT_OF - template - static has_cxx_eleven_result testFunctor(T const *, typename std::result_of::type const * = 0); -#endif static has_none testFunctor(...); // note that the following indirection is needed for gcc-3.3 @@ -209,28 +205,19 @@ template struct binary_result_of_select {typedef typename Func::template result::type type;}; -#ifdef EIGEN_HAS_STD_RESULT_OF -template -struct binary_result_of_select -{typedef typename std::result_of::type type;}; -#endif - template struct result_of { template static has_std_result_type testFunctor(T const *, typename T::result_type const * = 0); template static has_tr1_result testFunctor(T const *, typename T::template result::type const * = 0); -#ifdef EIGEN_HAS_STD_RESULT_OF - template - static has_cxx_eleven_result testFunctor(T const *, typename std::result_of::type const * = 0); -#endif static has_none testFunctor(...); // note that the following indirection is needed for gcc-3.3 enum {FunctorType = sizeof(testFunctor(static_cast(0)))}; typedef typename binary_result_of_select::type type; }; +#endif /** \internal In short, it computes int(sqrt(\a Y)) with \a Y an integer. * Usage example: \code meta_sqrt<1023>::ret \endcode