The std::for_each algorithm invokes the provided invocable on each range element in order, ignoring the result. The invocable can be stateful, and the algorithm returns it in its final state.
While the range-based for-loop has mostly replaced the use cases for std::for_each, it still comes in handy as a trivial parallelization tool through the C++17 parallel version.
Compiler Explorer link: https://compiler-explorer.com/z/EP7TnKev3