Created on 2010-11-17.00:00:00 last changed 89 months ago
Proposed resolution:
Adapt the following three rows from Table 44 — Allocator requirements:
Table 44 — Allocator requirements Expression Return type Assertion/note
pre-/post-conditionDefault X::propagate_on_container_copy_assignment Identical to or derived from true_type
or false_typetrue_type only if an allocator of type X should be copied
when the client container is copy-assigned. See Note B, below.false_type X::propagate_on_container_move_assignment Identical to or derived from true_type
or false_typetrue_type only if an allocator of type X should be moved
when the client container is move-assigned. See Note B, below.false_type X::propagate_on_container_swap Identical to or derived from true_type
or false_typetrue_type only if an allocator of type X should be swapped
when the client container is swapped. See Note B, below.false_type
Following [allocator.requirements] p. 3 insert a new normative paragraph:
Note B: If X::propagate_on_container_copy_assignment::value is true, X shall satisfy the CopyAssignable requirements (Table 39 [copyassignable]) and the copy operation shall not throw exceptions. If X::propagate_on_container_move_assignment::value is true, X shall satisfy the MoveAssignable requirements (Table 38 [moveassignable]) and the move operation shall not throw exceptions. If X::propagate_on_container_swap::value is true, lvalues of X shall be swappable ([swappable.requirements]) and the swap operation shall not throw exceptions.
Modify [container.requirements.general] p. 8 and p. 9 as indicated:
8 - [..] The allocator may be replaced only via assignment or swap(). Allocator replacement is performed by copy assignment, move assignment, or swapping of the allocator only if allocator_traits<allocator_type>::propagate_on_container_copy_assignment::value, allocator_traits<allocator_type>::propagate_on_container_move_assignment::value, or allocator_traits<allocator_type>::propagate_on_container_swap::value is true within the implementation of the corresponding container operation.
9 - The expression a.swap(b), for containers a and b of a standard container type other than array, shall exchange the values of a and b without invoking any move, copy, or swap operations on the individual container elements. Lvalues of aThe behavior of a call to a container's swap function is undefined unless the objects being swapped have allocators that compare equal or allocator_traits<allocator_type>::propagate_on_container_swap::value is true. In all container types defined in this Clause, the member get_allocator() returns a copy of the allocator used to construct the container or, if that allocator has been replaced, a copy of the most recent replacement.Any Compare, Pred, or Hashobjectstypes belonging to a and b shall be swappable and shall be exchanged byunqualified calls to non-membercalling swap as described in [swappable.requirements]. If allocator_traits<allocator_type>::propagate_on_container_swap::value is true, then lvalues of allocator_type shall be swappable and the allocators of a and b shall also be exchangedusing an unqualified call to non-memberby calling swap as described in [swappable.requirements]. Otherwise,theythe allocators shall not be swapped, and the behavior is undefined unless a.get_allocator() == b.get_allocator(). Every iterator referring to an element in one container before the swap shall refer to the same element in the other container after the swap. It is unspecified whether an iterator with value a.end() before the swap will have value b.end() after the swap.
[ 2014-02-14 Issaquah: Move to Ready ]
Fix a couple of grammar issues related to calling swap and move to Ready.
[ 2011-04-08 Pablo comments ]
I'm implementing a version of list now and I actually do find it impossible to write an exception-safe assignment operator unless I can assume that allocator assignment does not throw. (The problem is that I use a sentinel node and I need to allocate a new sentinel using the new allocator without destroying the old one -- then swap the allocator and sentinel pointer in atomically, without risk of an exception leaving one inconsistent with the other.
Please update the proposed resolution to add the nothrow requirement to copy-assignment.[ 2011-02-10 Alberto, Daniel, and Pablo collaborated on the proposed wording ]
The proposed resolution (based on N3225) attempts to solve the following problems:
During the Batavia meeting it turned out that there is a definition hole for types satisfying the Allocators requirements: The problem became obvious when it was discussed whether all swap functions of Containers with internal data handles can be safely tagged with noexcept or not. While it is correct that the implicit swap function of an allocator is required to be a no-throw operation (because move/copy-constructors and assignment operators are required to be no-throw functions), there are no such requirements for specialized swap overloads for a particular allocator.
But this requirement is essential because the Containers are required to support swappable Allocators, when the value allocator_traits<>::propagate_on_container_swap evaluates to true.History | |||
---|---|---|---|
Date | User | Action | Args |
2017-07-30 20:15:43 | admin | set | status: wp -> c++17 |
2014-11-08 19:44:42 | admin | set | status: voting -> wp |
2014-11-04 10:26:50 | admin | set | status: ready -> voting |
2014-02-17 17:08:46 | admin | set | messages: + msg6875 |
2014-02-17 17:08:46 | admin | set | status: open -> ready |
2011-11-21 23:16:34 | admin | set | messages: + msg5879 |
2011-02-16 18:24:26 | admin | set | status: new -> open |
2011-02-16 00:03:21 | admin | set | messages: + msg5494 |
2011-02-16 00:03:21 | admin | set | messages: + msg5493 |
2010-11-17 00:00:00 | admin | create |