Can a stack have an exception safe method for returning and removing the top element with move seman
Posted
by Motti
on Stack Overflow
See other posts from Stack Overflow
or by Motti
Published on 2010-04-12T06:58:07Z
Indexed on
2010/04/12
7:03 UTC
Read the original article
Hit count: 428
In an answer to a question about std::stack::pop()
I claimed that the reason pop
does not return the value is for exception safety reason (what happens if the copy constructor throws).
@Konrad commented that now with move semantics this is no longer relevant. Is this true?
AFAIK, move constructors can throw
, but perhaps with noexcept
it can still be achieved.
For bonus points what thread safety guarantees can this operation supply?
© Stack Overflow or respective owner