[polymorphic.swap] (original) (raw)

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);

Preconditions: If allocator_traits<Allocator>​::​propagate_on_container_swap​::​valueis true, thenAllocator meets the Cpp17Swappable requirements.

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

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

If allocator_traits<Allocator>​::​propagate_on_container_swap​::​valueis true, then the allocators of *this and otherare exchanged by calling swapas 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)));

Effects: Equivalent to lhs.swap(rhs).