From b9d008fa722ad7cee2802efe7b6a50e33e8f962b Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Fri, 30 Apr 2021 17:17:03 +0100 Subject: [PATCH] Added etl::for_each_iterator --- include/etl/algorithm.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/include/etl/algorithm.h b/include/etl/algorithm.h index 08ebfeda..7a6fcdf0 100644 --- a/include/etl/algorithm.h +++ b/include/etl/algorithm.h @@ -2733,6 +2733,28 @@ namespace etl return begin; } + //*************************************************************************** + /// Like std::for_each but passes the iterator to the function. + /// There is currently no STL equivalent. + ///\ingroup algorithm + //*************************************************************************** + template + TUnaryFunction for_each_iterator(TIterator begin, + const TIterator end, + TUnaryFunction function) + { + while (begin != end) + { + function(begin); + + ++begin; + } + + return function; + } + //*************************************************************************** /// A safer form of std::transform where the transform returns when the first /// range end is reached.