[Solved] discussion about the scenarios that the insertion function of an STL vector may not work [closed]


I can only assume that a side effect of calculateSomeValue() is changing a which invalidates all iterators.

Since the order of evaluation of arguments in a.insert(a.begin(), calculateSomeValue()); is unspecified it could be that a.begin() is evaluated before calculateSomeValue() invalidates all iterators to a. Which is undefined behaviour.

solved discussion about the scenarios that the insertion function of an STL vector may not work [closed]