From 4e234a91cdae81a28bd4a05ae72d286f64eb5e20 Mon Sep 17 00:00:00 2001 From: Max Lyon Date: Thu, 29 Oct 2020 10:34:12 +0100 Subject: [PATCH] fix/simplify FilteredSmartRange --- src/OpenMesh/Core/Mesh/SmartRange.hh | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/src/OpenMesh/Core/Mesh/SmartRange.hh b/src/OpenMesh/Core/Mesh/SmartRange.hh index c3fba9f0..6524042c 100644 --- a/src/OpenMesh/Core/Mesh/SmartRange.hh +++ b/src/OpenMesh/Core/Mesh/SmartRange.hh @@ -428,27 +428,10 @@ struct SmartRangeT * @param f Functor that needs to be evaluated to true if the element should not be skipped. */ template - auto filtered(Functor&& f) -> FilteredSmartRangeT::type> + auto filtered(Functor&& f) -> FilteredSmartRangeT { auto range = static_cast(this); - auto b = (*range).begin(); - auto e = (*range).end(); - return FilteredSmartRangeT::type>(f, b, e); - } - - /** @brief Only iterate over a subset of elements - * - * Returns a smart range which skips all elements that do not satisfy functor \p f - * - * @param f Functor that needs to be evaluated to true if the element should not be skipped. - */ - template - auto filtered(Functor& f) -> FilteredSmartRangeT::type&> - { - auto range = static_cast(this); - auto b = (*range).begin(); - auto e = (*range).end(); - return FilteredSmartRangeT::type&>(f, b, e); + return FilteredSmartRangeT(std::forward(f), (*range).begin(), (*range).end()); } }; @@ -488,11 +471,12 @@ struct FilteredSmartRangeT : public SmartRangeT(f)), begin_(std::move(begin)), end_(std::move(end)){} FilteredIterator begin() const { return FilteredIterator(f_, begin_, end_); } FilteredIterator end() const { return FilteredIterator(f_, end_, end_); }