I just realize the standard doesn't guarantee the order of applying function callback in
This non-restrictive definition allows for parallel computing. An implementation may choose to apply transform function using several threads. See also related question: STL algorithms and concurrent programming
Think of it as a semantic difference in algorithms (that is, that represents programmer's intent rather than being just another tool). With
for_each you state that you need a sequential scan. With
transform you state that you only need to aply a function to every item in the container, but you don't care how it will be done.