Files
2025-10-25 03:02:53 +03:00

1.8 KiB
Raw Permalink Blame History

[polymorphic.swap]

20 Memory management library [mem]

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

20.4.2 Class template polymorphic [polymorphic]

20.4.2.7 Swap [polymorphic.swap]

🔗

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

1

#

Preconditions: If allocator_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(polymorphic& lhs, polymorphic& rhs) noexcept(noexcept(lhs.swap(rhs)));

3

#

Effects: Equivalent to lhs.swap(rhs).