friend void swap(jthread& x, jthread& y) noexcept;
概要
2つのjthread
オブジェクトを入れ替える
効果
x.swap(y);
戻り値
なし
例外
投げない
例
#include <thread>
int main()
{
std::jthread t1([]{ /*...*/ });
std::jthread t2;
swap(t1, t2);
t2.join();
return 0;
}
出力
バージョン
言語
- C++20
処理系
- Clang:
- GCC: 10.2.0 ✅
- Visual C++: ??