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

履歴 編集

function
<thread>

std::jthread::swap (非メンバ関数)(C++20)

friend void swap(jthread& x, jthread& y) noexcept;

概要

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

効果

x.swap(y);

戻り値

なし

例外

投げない

#include <thread>

int main()
{
  std::jthread jt1([]{ /*...*/ });
  std::jthread jt2;

  swap(jt1, jt2);

  jt2.join();

  return 0;
}

出力

バージョン

言語

  • C++20

処理系