C++11 §23.2.1.10 specifies:
Unless otherwise specified all container types defined in this Clause meet the following additional requirements:
- if an exception is thrown by an insert() or emplace() function while inserting a single element, that function has no effects.
- no erase() , clear() , pop_back() or pop_front() function throws an exception.
Regarding the first bullet point, How does the container guarantee that?
The constructor for T
might have side-effects. Should it not be "has no effect on the container"
Regarding the second bullet point, This normally calls allocator::deallocate(T*,size_t)
which is not noexcept
. Why should eventual exceptions be masked away?
Table 28 specifies one of the requirements of an allocator is that deallocate()
"Does not throw exceptions". That is how the standard can make the assertion about erase()
, clear()
, pop_back()
and pop_front()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With