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

履歴 編集

function
<thread>

std::jthread::joinable(C++20)

bool joinable() const noexcept;

概要

jthreadオブジェクトがスレッドと関連付けられているか否か取得する。

戻り値

return get_id() != id();

例外

送出しない。

#include <cassert>
#include <thread>

int main()
{
  std::jthread t([]{ /*...*/ });
  assert(t.joinable());

  t.join();
  assert(!t.joinable());
}

出力

バージョン

言語

  • C++20

処理系