最終更新日時:
が更新

履歴 編集

function
<memory>

std::pointer_tag_pair::swap(C++29)

constexpr void swap(pointer_tag_pair& o) noexcept; // (1) C++29

概要

他のpointer_tag_pairオブジェクトと値を入れ替える。

効果

*thisoの値を交換する。

例外

投げない。

#include <memory>
#include <iostream>

int main()
{
  int x = 1;
  int y = 2;
  std::pointer_tag_pair<int*, 1, bool> p{&x, false};
  std::pointer_tag_pair<int*, 1, bool> q{&y, true};

  p.swap(q);

  std::cout << *p.pointer() << ':' << p.tag() << std::endl;
}

出力

2:1

バージョン

言語

  • C++29

処理系

参照