Skip to main content
Stack Overflow
  1. About
  2. For Teams

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

Required fields*

pop_back() return value?

Why doesn't pop_back() have a return value? I have Googled regarding this and found out that it makes it more efficient. Is this the only reason for making it so in the standard?

Answer*

Draft saved
Draft discarded
Cancel
9
  • 5
    +1 for the reference to Tom Cargill paper "Excpetion handling: a false sense of security". A MUST-READ. :-) Commented Sep 26, 2012 at 11:19
  • 2
    If I remember correctly then "The C++ Language" or some edition of "Effective C++" actually claimed that it was for efficiency reasons because they hadn’t figured out move construction and NRVO then. Commented Sep 26, 2012 at 12:24
  • @Konrad: AFAIR, Meyers even pointed at Cargill's paper. (Come to think of it, I bet that's the actual reason why a copy of it exists, at Pearson's website.) Commented Sep 26, 2012 at 12:28
  • How can we be sure that a removed object does not throw in destructor? I understand that it shouldn't, but how can we control it? Commented Apr 28, 2014 at 9:15
  • 7
    @Mikhail: If destructors throw, you cannot guarantee anything. That's the reason they must not. Again: Destructors must never throw. Period. If you write a dtor that lets escape an exception, you might just as well dereference NULL. Commented May 5, 2014 at 14:14

lang-cpp

AltStyle によって変換されたページ (->オリジナル) /