-1

(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

4

2 に答える 2

2

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.

于 2013-03-03T22:46:41.770 に答える
0

std::allocators requirements make its constructors noexcept, as it says shall not exit via an exception. However, the deque's constructor can throw as it is not noexcept.

于 2013-03-03T22:47:31.743 に答える