In §25.2.4.2 of the C++ standard (std::for_each
):
template<class InputIterator, class Function> Function
for_each(InputIterator first, InputIterator last, Function f);
Effects: Applies f to the result of dereferencing every iterator in the range [first,last), starting from first and proceeding to last - 1.
- Does this mean that f is applied to the elements of a container in order?
- If so, does the parallel mode of libstdc++ violate it?
- If not, why is the range-based for loop in §6.5.4 not implemented as a call to std::for_each? (this would allow range-based for loops to also be automatically parallelized by the implementation)