Created on 2007-12-22.00:00:00 last changed 172 months ago
Proposed resolution:
Create a new sub-section of [associative.reqmts] (perhaps [associative.req.except]) titled "Exception safety guarantees".
1 For associative containers, no clear() function throws an exception. erase(k) does not throw an exception unless that exception is thrown by the container's Pred object (if any).
2 For associative containers, if an exception is thrown by any operation from within an insert() function inserting a single element, the insert() function has no effect.
3 For associative containers, no swap function throws an exception unless that exception is thrown by the copy constructor or copy assignment operator of the container's Pred object (if any).
Change [unord.req.except]p1:
For unordered associative containers, no clear() function throws an exception.
Noerase(k)functiondoes not throwsan exception unless that exception is thrown by the container's Hash or Pred object (if any).
Change [container.requirements] p10 to add references to new sections:
Unless otherwise specified (see [deque.modifiers],
and[vector.modifiers], [associative.req.except], [unord.req.except]) all container types defined in this clause meet the following additional requirements:
Change [container.requirements] p10 referring to swap:
- no swap() function throws an exception
unless that exception is thrown by the copy constructor or assignment operator of the container's Compare object (if any; see [associative.reqmts]).
[container.requirements]p10 states:
Unless otherwise specified (see 23.2.2.3 and 23.2.5.4) all container types defined in this clause meet the following additional requirements:
- [...]
- no erase(), pop_back() or pop_front() function throws an exception.
[deque.modifiers] and [vector.modifiers] offer additional guarantees for deque/vector insert() and erase() members. However, [container.requirements] p10 does not mention [unord.req.except] that specifies exception safety guarantees for unordered containers. In addition, [unord.req.except] p1 offers the following guaratee for erase():
No erase() function throws an exception unless that exception is thrown by the container's Hash or Pred object (if any).
Summary:
According to [container.requirements] p10 no erase() function should throw an exception unless otherwise specified. Although does not explicitly mention [unord.req.except], this section offers additional guarantees for unordered containers, allowing erase() to throw if predicate or hash function throws.
In contrast, associative containers have no exception safety guarantees section so no erase() function should throw, including erase(k) that needs to use the predicate function to perform its work. This means that the predicate of an associative container is not allowed to throw.
So:
History | |||
---|---|---|---|
Date | User | Action | Args |
2010-10-21 18:28:33 | admin | set | messages: + msg3702 |
2007-12-22 00:00:00 | admin | create |