最終更新日時(UTC):
が更新

履歴 編集

function
<memory>

std::indirect::swap(C++26)

friend constexpr void swap(indirect& lhs, indirect& rhs) noexcept(see below);

概要

2つのindirectオブジェクトを交換する。Hidden friendsとして定義される。

効果

lhs.swap(rhs)と等価。

例外

以下と等価なnoexcept指定を持つ:

noexcept(noexcept(lhs.swap(rhs)))

#include <cassert>
#include <memory>

int main()
{
  std::indirect<int> a{1};
  std::indirect<int> b{2};
  swap(a, b);   // ADLにより非メンバswapが呼ばれる
  assert(*a == 2 && *b == 1);
}

出力

バージョン

言語

  • C++26

処理系

関連項目

参照