56 lines
1.8 KiB
Markdown
56 lines
1.8 KiB
Markdown
[indirect.swap]
|
||
|
||
# 20 Memory management library [[mem]](./#mem)
|
||
|
||
## 20.4 Types for composite class design [[mem.composite.types]](mem.composite.types#indirect.swap)
|
||
|
||
### 20.4.1 Class template indirect [[indirect]](indirect#swap)
|
||
|
||
#### 20.4.1.7 Swap [indirect.swap]
|
||
|
||
[ð](#lib:swap,indirect)
|
||
|
||
`constexpr void swap(indirect& other)
|
||
noexcept(allocator_traits<Allocator>::propagate_on_container_swap::value ||
|
||
allocator_traits<Allocator>::is_always_equal::value);
|
||
`
|
||
|
||
[1](#1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L6620)
|
||
|
||
*Preconditions*: Ifallocator_traits<Allocator>::propagate_on_container_swap::value is true, thenAllocator meets the *Cpp17Swappable* requirements[.](#1.sentence-1)
|
||
|
||
Otherwise get_allocator() == other.
|
||
get_allocator() is true[.](#1.sentence-2)
|
||
|
||
[2](#2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L6628)
|
||
|
||
*Effects*: Swaps the states of *this and other,
|
||
exchanging owned objects or valueless states[.](#2.sentence-1)
|
||
|
||
If allocator_traits<Allocator>::propagate_on_container_swap::value is true,
|
||
then the allocators of *this and other are exchanged by calling swap as described in [[swappable.requirements]](swappable.requirements "16.4.4.3 Swappable requirements")[.](#2.sentence-2)
|
||
|
||
Otherwise,
|
||
the allocators are not swapped[.](#2.sentence-3)
|
||
|
||
[*Note [1](#note-1)*:
|
||
|
||
Does not call swap on the owned objects directly[.](#2.sentence-4)
|
||
|
||
â *end note*]
|
||
|
||
[ð](#itemdecl:2)
|
||
|
||
`constexpr void swap(indirect& lhs, indirect& rhs) noexcept(noexcept(lhs.swap(rhs)));
|
||
`
|
||
|
||
[3](#3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/memory.tex#L6650)
|
||
|
||
*Effects*: Equivalent to lhs.swap(rhs)[.](#3.sentence-1)
|