From 4c15ff6e60af4a9f72bcd840ee5c0034e4007c18 Mon Sep 17 00:00:00 2001 From: Max Lyon Date: Thu, 17 Oct 2019 16:02:00 +0200 Subject: [PATCH] add any of and all of to smart ranges --- src/OpenMesh/Core/Mesh/SmartRange.hh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/OpenMesh/Core/Mesh/SmartRange.hh b/src/OpenMesh/Core/Mesh/SmartRange.hh index 8b40e6e2..07299d48 100644 --- a/src/OpenMesh/Core/Mesh/SmartRange.hh +++ b/src/OpenMesh/Core/Mesh/SmartRange.hh @@ -116,6 +116,26 @@ struct SmartRangeT return (1.0 / n_elements) * sum; } + template + auto any_of(Functor&& f) -> bool + { + auto range = static_cast(this); + for (auto e : *range) + if (f(e)) + return true; + return false; + } + + template + auto all_of(Functor&& f) -> bool + { + auto range = static_cast(this); + for (auto e : *range) + if (!f(e)) + return false; + return true; + } + /** @brief Convert range to array. * * Converts the range of elements into an array of objects returned by functor \p f.