Is there any reason that std::deque's pop_front() and pop_back() are not noexcept in C++11 and higher or was that just forgotten?
What the compiler tells you is rather straight forward: the pop_front() function does not returns the value of the front element. It simply removes it from the container. To access the element at front, you need to use the access function front() .
pop_back() function is used to pop or remove elements from a deque from the back. The value is removed from the deque from the end, and the container size is decreased by 1. If the deque is empty, it shows undefined behaviour.
If I understood correctly, the standard doesn't specify noexcept on functions with a narrow contract (with a precondition which violation leads to UB). N3279 and more recently P0884 are talking about this and about how to decide whether a function should be noexcept or not (or conditionally).
This is the case for std::deque's pop_front and pop_back but also on front and back where there is no call to a destructor. Same for std::vector's pop_back, front and back for example.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With