There is a slight difference that push_back returns void whether the insert iterator returns the element just inserted.
By the way, there is another way to check if they are doing the same thing: compile the following codes
int main() { std::vector<int const> v; v.push_back(0); return 0; }
the compiler will print a lot of annoying messages, just read it and you will find push_back calls insert (if not, try compiling v.insert(v.end(), 0) to see if they called the same insert function) at the end .
neuront May 11 '11 at 9:05 a.m. 2011-05-11 09:05
source share