From 8fa5f36d1330a0a96a7058410c2348b1cc35372d Mon Sep 17 00:00:00 2001 From: Max Lyon Date: Thu, 28 Nov 2019 11:50:03 +0100 Subject: [PATCH] make SmartRange sum and avg compatible with Eigen vectors --- src/OpenMesh/Core/Mesh/SmartRange.hh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/OpenMesh/Core/Mesh/SmartRange.hh b/src/OpenMesh/Core/Mesh/SmartRange.hh index 5f925e0d..affaeb71 100644 --- a/src/OpenMesh/Core/Mesh/SmartRange.hh +++ b/src/OpenMesh/Core/Mesh/SmartRange.hh @@ -78,13 +78,13 @@ struct SmartRangeT * @param f Functor that is applied to all elements before computing the sum */ template - auto sum(Functor&& f) -> decltype (f(std::declval())+f(std::declval())) + auto sum(Functor&& f) -> decltype (f(std::declval())) { auto range = static_cast(this); auto begin = range->begin(); auto end = range->end(); assert(begin != end); - decltype (f(*begin) + f(*begin)) sum = f(*begin); + decltype (f(*begin)) sum = f(*begin); auto it = begin; ++it; for (; it != end; ++it) @@ -99,13 +99,13 @@ struct SmartRangeT * @param f Functor that is applied to all elements before computing the average. */ template - auto avg(Functor&& f) -> decltype (1.0 * (f(std::declval())+f(std::declval()))) + auto avg(Functor&& f) -> decltype (f(std::declval())) { auto range = static_cast(this); auto begin = range->begin(); auto end = range->end(); assert(begin != end); - decltype (f(*begin) + f(*begin)) sum = f(*begin); + decltype (f(*begin)) sum = f(*begin); auto it = begin; ++it; int n_elements = 1;