This allows std::is_nothrow_swappable{,_with} to work properly.
This only touches user-facing classes, with the following exceptions:
- map,set: only doc changes (with a drive-by missing semicolon fix),
detail::tree which they derive from already forwards noexcept for swap.
- flat_set: only doc changes for flat_set and a change for
detail::flat_tree, which it derives from to get swap.
- static_vector: while this adds the forwarding, member static_vector::swap
is currently never noexcept, although it could be for noexcept-swappable
and noexcept-move-constructible elements.
- small_vector: there is no free swap, and member swap is never noexcept,
although it could be for noexcept-swappable and noexcept-move-
constructible elements. Swapping small_vectors of exact same type goes
through std::swap, which seems to get noexcept right, and small_vectors
of different sizes use swap for boost::container::vector, which fails
to detect when such swap could be noexcept. This patch doesn't touch
small_vector.
- scoped_allocator: neither member nor free swap are noexcept, although
they should be, and all other constructions/assignments/comparisons too,
as they only forward these operations to underlying allocators, which
are required to not throw exceptions for them. Only static_vector's
static_storage_allocator might throw for these and it shouldn't appear
in scoped_allocator. Unsure of the scope of changes needed or whether it
is even worth it, this patch doesn't touch scoped_allocator.
Most template type parameters 'Allocator' were modified their default type to void since 1.70.0.
These modifications cause has_trivial_destructor_after_move to compile error or yield wrong result.
So, fix them by changing specializations of has_trivial_destructor_after_move.
Many existing constructors have this form:
map(std::initializer_list<value_type> il, const Compare& comp = Compare(), const allocator_type& a = allocator_type())
The issue is that a temporary allocator_type is constructed, and
passed to the base class where it is used to copy-constructed the
rebound allocator.
This temporary allocator_type here is always destroyed at the end
of the map() constructor. For stateful allocators this is not
desirable.
The solution is to adopt what libc++ is doing and have to constructors:
map(std::initializer_list<value_type> il, const Compare& comp = Compare(), const allocator_type& a)
and
map(std::initializer_list<value_type> il, const Compare& comp = Compare())
This way, unless an allocator is provided by the client, no extra temporary
creation/destruction occurs.
* Optimized insert_equal(ordered_range_t,...) and insert_unique(ordered_unique_range_t, ...) for elements to be inserted in the end.
* Added range insertion overload (non-standard extension) to vector taking the number of elements to avoid reiterations with std::distance.