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.