b***n 发帖数: 590 | 1 member functions of the C++ (SGI STL, according to Hou's book)
STL list container:
void pop_front() {erase(begin());}
void pop_back() {iterator tmp=end(); erase(--tmp);}
For the pop_back(), why not juse write as:
void pop_back() {erase(--end());}
looks like it should also work.
Thanks! | t****t 发帖数: 6806 | 2 sure it works. in fact your way is the Standard way.
【在 b***n 的大作中提到】 : member functions of the C++ (SGI STL, according to Hou's book) : STL list container: : void pop_front() {erase(begin());} : void pop_back() {iterator tmp=end(); erase(--tmp);} : For the pop_back(), why not juse write as: : void pop_back() {erase(--end());} : looks like it should also work. : Thanks!
|
|