Is generate Guaranteed to be Executed Sequentially?
I was told here that: The order of generate is not guaranteed => depending on the implementation I have looked up gcc's implementation of generate : for (; __first != __last; ++__first) *__first = __gen(); And Visual Studio implements it identically to that. This is a relief to me as using a lambda in generate that reads and writes to a capture could have undeterministic results: int foo[] = {1, 0, 13}; vector<int> bar(3); generate(bar.begin(), bar.end(), [&]() { static auto i = 0; static auto total = 0; total += foo[i]; return foo[i] / total; }); I expect bar to contain {1, 0, 0} . If I am