Added etl::for_each_iterator

This commit is contained in:
John Wellbelove 2021-04-30 17:17:03 +01:00 committed by John Wellbelove
parent 421244b7b9
commit b9d008fa72

View File

@ -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 <typename TIterator,
typename TUnaryFunction,
typename TUnaryPredicate>
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.