Using C++ vector::insert() to add to end of vector

a.push_back(x) is defined to have identical semantics to (void)a.insert(a.end(),x) for sequence containers that support it.

See table 68 in ISO/IEC 14882:2003 23.1.1/12 [lib.sequence.reqmts].

Screenshot of Table 68 taken from International Standard ISO/IEC 14882:2003 at

Regarding the running time of vector.push_back(x) vs. vector.insert(vector.end(), x) consider the emphasized part:

Table 68 lists sequence operations that are provided for some types of sequential containers but not others. An implementation shall provide these operations for all container types shown in the ‘‘container’’ column, and shall implement them so as to take amortized constant time.

Leave a Comment