Yes. & dagger; The standard refers to this in general requirements:
<sub> [C++11: Β§23.2.1/10]: sub>
Unless otherwise specified (see 23.2.4.1, 23.2.5.1, 23.3.3.4 and 23.3.6.5), all container types defined in this section satisfy the following additional requirements:
- the function erase (), clear (), pop_back () or pop_front () does not throw an exception.
Using the clear function as an example (because of this, it is no exception to the general requirement), it has the following requirements:
Destroys all elements in a. The invalidity of all references, pointers, and iterators related to the elements of a can invalidate the iterator of the past end. Message: a.empty() returns true
This means that it essentially calls std::allocator_traits<Alloc>::destroy for all elements. To whom t->~T() delegated if a.destroy(t) not available. However, this implicitly guarantees that neither a.destroy(t) nor t->~T() should be thrown because it violates the clear strong noexcept :
Thus, thanks to the deduction, we could argue that destructors can throw, but they need to be suppressed using some mechanism, for example, wrapping them in a try-catch block.
& dagger ;: Upon further inspection, it seems that destructors can throw, but exceptions should be suppressed, as indicated in the comments below.