vendredi 27 mars 2015

Are STL container elements explicitly required to be (noexcept) destructible?

C++11 (and C++14) STL containers have noexcept destructors and clear() member functions.


This implies that the elements should have noexcept destructors too, or at least that the actual elements stored in containers should not throw any exceptions when destroyed—or more correctly, that the corresponding allocator_traits<Allocator>::destroy call should not throw.


Is this specified as a requirement (explicitly or implied by another explicit requirement) anywhere in the standard? If not, why?


I know is_nothrow_constructible requires a noexcept destructor, but is_constructible alone doesn’t, and container requirements are specified in terms of concepts rather than type traits templates anyway.


Aucun commentaire:

Enregistrer un commentaire