add for_each to smart ranges

This commit is contained in:
Max Lyon
2020-03-24 15:40:26 +01:00
parent 470b46d96c
commit 290f8f5414
2 changed files with 34 additions and 4 deletions

View File

@@ -371,6 +371,21 @@ struct SmartRangeT
}
/** @brief Apply a functor to each element.
*
* Calls functor \p f with each element as parameter
*
* @param f Functor that is called for each element.
*/
template <typename Functor>
auto for_each(Functor&& f) -> void
{
auto range = static_cast<const RangeT*>(this);
for (const auto& e : *range)
f(e);
}
};