Files
cppdraft_translate/cppdraft/indirect/swap.md
2025-10-25 03:02:53 +03:00

1.8 KiB
Raw Blame History

[indirect.swap]

20 Memory management library [mem]

20.4 Types for composite class design [mem.composite.types]

20.4.1 Class template indirect [indirect]

20.4.1.7 Swap [indirect.swap]

🔗

constexpr void swap(indirect& other) noexcept(allocator_traits<Allocator>::propagate_on_container_swap::value || allocator_traits<Allocator>::is_always_equal::value);

1

#

Preconditions: Ifallocator_traits::propagate_on_container_swap::value is true, thenAllocator meets the Cpp17Swappable requirements.

Otherwise get_allocator() == other.
get_allocator() is true.

2

#

Effects: Swaps the states of *this and other, exchanging owned objects or valueless states.

If allocator_traits::propagate_on_container_swap::value is true, then the allocators of *this and other are exchanged by calling swap as described in [swappable.requirements].

Otherwise, the allocators are not swapped.

[Note 1:

Does not call swap on the owned objects directly.

— end note]

🔗

constexpr void swap(indirect& lhs, indirect& rhs) noexcept(noexcept(lhs.swap(rhs)));

3

#

Effects: Equivalent to lhs.swap(rhs).