Topic: STL pop_back()
Author: Hayden Schultz <haydens@tiac.net>
Date: 1996/03/05 Raw View
According to _STL Tutorial and Reference Guide_ by Musser and Saini
(a very good book, btw), the following functions are defined:
template <class T> void vector<t>::pop_back();
template <class T> void deque<t>::pop_back();
template <class T> void deque<t>::pop_front();
template <class T> void list<t>::pop_back();
template <class T> void list<t>::pop_front();
Other classes may have pop functions, I dunno.
Why don't the pop functions return a copy of the object before they
blow it away? Another possibility, I suppose, would be an auto_ptr<T>
so that the object is deleted if it's not used. An auto_ptr<T> is
about as efficient as deleting it in the pop function, it just changes
the time it's deleted (which isn't guaranteed anywhere I've read
anyway).
Why call the methods push and pop if it doesn't act like a stack?
It's not really a big deal (it's easy enough to write my own adapter).
I'm just curious.
Thanks,
Hayden Schultz
Ptech, Inc.
haydens@tiac.net
hayden@ptechinc.com
---
[ To submit articles: try just posting with your news-reader.
If that fails, use mailto:std-c++@ncar.ucar.edu
FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html
Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html
Comments? mailto:std-c++-request@ncar.ucar.edu.
]