Search code examples
c++c++11dequestdnoexcept

Why are deque's pop_front() and pop_back() not noexcept?


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?


Solution

  • 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.