Here is the code:
listOfFoos::iterator new_foo_it = listOfFoos.insert(listOfFoos.end(),newFoo);
listOfFoos
is just that, a std::list
of foo
objects. Normally you would write:
listOfFoos::iterator new_foo_it = listOfFoos.begin();
I also understand that the list.insert()
will insert a newFoo
at the specified index, then the iterator will be created. But I don't know how the insert affects the iterator's position.
It is well documented in the manual.
An iterator that points to the first of the newly inserted elements.
In you case new_foo_it
after listOfFoos.insert
of a single element, points to the last element of the list, it points newFoo
.