I\'m using Visual Studio 2015 Update 1 C++ compiler and this code snippet:
#include
#include
using namespace std;
int main(
According to documentation:
If the new size() is greater than capacity() then all iterators and references (including the past-the-end iterator) are invalidated. Otherwise only the past-the-end iterator is invalidated.
It says even if capacity is enough past-the-end iterator is invalidated, so I believe your code has UB (unless this documentation is incorrect and standard says otherwise)