Search code examples
c++stldeque

Does default constructor of deque throw?


(Assuming allocator's default constructor does not throw)

Boost implementation of Deque says:

Throws if allocator_type's default constructor throws

What does C++ standard specify ?

Thanks


Solution

  • The C++11 Standard (Paragraph 23.3.3.2) specifies:

    explicit deque(const Allocator& = Allocator());
    

    1 Effects: Constructs an empty deque, using the specified allocator.

    2 Complexity: Constant.

    That's it. No mention is made of the conditions under which this constructor may or may not throw, nor does Clause 23 (dedicated to sequence containers) specify any general exception safety guarantees, and the constructor itself is not marked as (conditionally) noexcept.

    Therefore, one must just assume it can throw.