vector v; X x; v.push_back(x); v.push_back(x); v.push_back(x);
Why this code calls the copy constructor of a class X
X
You can use vector reserve to create space in the vector before hand to speed up adding elements to a vector as well as stopping this from happening.