From 227b1cd5c7a3d4ca37d7fa64bc153649108cc43a Mon Sep 17 00:00:00 2001 From: Max Lyon Date: Mon, 9 Mar 2020 18:43:21 +0100 Subject: [PATCH] add count_if to smart ranges --- src/OpenMesh/Core/Mesh/SmartRange.hh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/OpenMesh/Core/Mesh/SmartRange.hh b/src/OpenMesh/Core/Mesh/SmartRange.hh index b827137a..5518878e 100644 --- a/src/OpenMesh/Core/Mesh/SmartRange.hh +++ b/src/OpenMesh/Core/Mesh/SmartRange.hh @@ -353,7 +353,16 @@ struct SmartRangeT } - + template + auto count_if(Functor&& f) -> int + { + int count = 0; + auto range = static_cast(this); + for (const auto& e : *range) + if (f(e)) + ++count; + return count; + } };