I know std::queue::pop()
returns void
. For two reasons:
- exception safety: something might throw after removing the element
- to be able to return the value by reference
Fine.
Now if I understand the new C++11 move semantics correctly, the second is no longer a valid argument.
So... the only thing preventing std::queue
to have a pop
-like function returning the value lies in the possibility that the move constructor throws?
I have a hard time thinking of situations where such a move constructor would throw. Who knows of an example?
I guess the same goes for std::stack::pop()
, std::vector::pop_front()
, std::vector::pop_back()
, std::deque::pop_front()
, std::deque::pop_back()
, std::list::pop_front()
, std::list::pop_back()
and what not.