std::polymorphic<T, Allocator>::swap
From cppreference.com
constexpr void swap( polymorphic& other ) noexcept(/* see below */); |
(since C++26) | |
Swaps the contents with those of other.
In the description below, swap_allocators refers to std::allocator_traits<Allocator>::propagate_on_container_swap::value.
Swaps the states of *this and other, exchanging owned objects or valueless states.
- If
swap_allocatorsistrue, then executesusing std::swap;swap(alloc, other.alloc);. - Otherwise, the allocators are not swapped.
If one of the following conditions is satisfied, the behavior is undefined:
swap_allocatorsistrue, andAllocatordoes not satisfy the requirements of Swappable.swap_allocatorsisfalse, andget_allocator() == other.get_allocator()isfalse.
Parameters
| other | - | the polymorphic object to exchange the contents with
|
Exceptions
noexcept specification:
noexcept(std::allocator_traits<Allocator>::propagate_on_container_swap::value || std::allocator_traits<Allocator>::is_always_equal::value)Example
| This section is incomplete Reason: no example |
See also
(C++26) |
specializes the std::swap algorithm (function template) |