In C++20 (N4849), there is no exception safety wording for associative containers' extract()
and insert(node_handle)
/insert(hint, node_handle)
methods.
But for merge()
, there is this wording though:
Throws: Nothing unless the comparison object throws.
Location:
22.2.6 Associative containers [associative.reqmts]
Table 78: Associative container requirements (in addition to container) [tab:container.assoc.req]
Page 799
Apparently the orignal proposal (P0083R3) intended to make it no-throw (page 5):
Exception safety
If the container’s Compare function is no-throw (which is very common), then removing a node, modifying it, and inserting it is no-throw unless modifying the value throws. And if modifying the value does throw, it does so outside of the containers involved.
But why is there no say in the proposed wording later in that proposal?
The insert
members taking a node handle have a precondition that the allocator in the node handle compares equal to the container's allocator.
The extract
members taking an iterator have a precondition that the iterator is a valid dereferenceable iterator into the container.
The policy of the standard library is that functions with runtime preconditions are not noexcept
.
The extract
member taking a key_type
argument can only throw if the comparison function throws, but that still means it can't be noexcept
.
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