Spec-Zone.ru › C++

std::indirect<T, Allocator>::swap

constexpr void swap( indirect& 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_allocators is true, then executes usingstd::swap;
    swap(alloc ,other.alloc );
    .
  • Otherwise, the allocators are not swapped.

If one of the following conditions is satisfied, the behavior is undefined:

  • swap_allocators is true, and Allocator does not satisfy the requirements of Swappable.
  • swap_allocators is false, and get_allocator() == other.get_allocator() is false.

Parameters

other - the indirect 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

See also

std::swap(std::indirect)
(C++26)
specializes the std::swap algorithm
(function template)

© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
https://en.cppreference.com/cpp/memory/indirect/swap

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API