When looking over the member functions of the STL containers, an odd thought occurred to me. Why don\'t functions like std::vector
not ha
Because there's .back() that will instantly return it for you?
Conceptually, the C++ designers won't implement in a member function anything that would be difficult or impossible for you to implement in a public interface. Calling .back() is simple and easy enough. For an iterator, you could do (end - 1) or just auto it = end; it--;
The Standards committee makes new code possible and massively simplifies code that is very commonly used. Stuff like this just isn't on the list of things to do.
v.insert(v.end(),x);
Would be equivalent to push_back with returning an iterator. Why push_back itself doesn't return an iterator is beyond me.