Difference between revisions of "Template:cpp/container/swap"
From cppreference.com
(merge noexcept) |
m (Text replace - "{{concept" to "{{named req") |
||
Line 15: | Line 15: | ||
{{#switch:{{{1|}}} | {{#switch:{{{1|}}} | ||
− | |map | set | multimap | multiset=The {{tt|Pred}} objects must be {{ | + | |map | set | multimap | multiset=The {{tt|Pred}} objects must be {{named req|Swappable}}, and they are exchanged using unqualified call to non-member {{tt|swap}}. |
− | |unordered_map | unordered_set | unordered_multimap| unordered_multiset=The {{tt|Hash}} and {{tt|KeyEqual}} objects must be {{ | + | |unordered_map | unordered_set | unordered_multimap| unordered_multiset=The {{tt|Hash}} and {{tt|KeyEqual}} objects must be {{named req|Swappable}}, and they are exchanged using unqualified calls to non-member {{tt|swap}}. |
}} | }} | ||
{{rev begin}} | {{rev begin}} |
Revision as of 14:16, 15 June 2018
void swap( {{{1}}}& other ); |
(since {std}) (until C++17) |
|
void swap( {{{1}}}& other ) noexcept(/* see below */); |
(since C++17) | |
Exchanges the contents of the container with those of other
. Does not invoke any move, copy, or swap operations on individual elements.
Information on iterator invalidation is copied from here |
If std::allocator_traits<allocator_type>::propagate_on_container_swap::value is true, then the allocators are exchanged using an unqualified call to non-member swap . Otherwise, they are not swapped (and if get_allocator() != other.get_allocator(), the behavior is undefined). |
(since C++11) |
Contents |
Parameters
other | - | container to exchange the contents with |
Return value
(none)
Exceptions
(none) |
(until C++17) | ||
|
(since C++17) |
Complexity
Constant.
See also
specializes the std::swap algorithm (function template) |