Skip to content

Latest commit

 

History

History
70 lines (51 loc) · 1.08 KB

File metadata and controls

70 lines (51 loc) · 1.08 KB

swap (非メンバ関数)

  • stop_token[meta header]
  • std[meta namespace]
  • stop_source[meta class]
  • function[meta id-type]
  • cpp20[meta cpp]
friend void swap(stop_source& x, stop_source& y) noexcept;

概要

2つのstop_sourceオブジェクトを入れ替える。

効果

以下と等価:

x.swap(y);
  • swap[link swap.md]

戻り値

なし

例外

なし

#include <cassert>
#include <stop_token>

int main()
{
  std::stop_source ss1;
  std::stop_source ss2(std::nostopstate);

  assert(ss1.stop_possible() == true);
  assert(ss2.stop_possible() == false);

  swap(ss1, ss2);

  assert(ss1.stop_possible() == false);
  assert(ss2.stop_possible() == true);
}
  • swap[color ff0000]
  • stop_source[link ../stop_source.md]
  • nostopstate[link ../nostopstate.md]
  • stop_possible()[link stop_possible.md]

出力

バージョン

言語

  • C++20

処理系