[[nodiscard]] bool joinable() const noexcept; // (1) C++20
bool joinable() const noexcept; // (1) C++26
概要
jthreadオブジェクトがスレッドと関連付けられているか否か取得する。
戻り値
例外
送出しない。
例
#include <cassert>
#include <thread>
int main()
{
std::jthread jt([]{ /*...*/ });
assert(jt.joinable());
jt.join();
assert(!jt.joinable());
}
出力
バージョン
言語
- C++20
処理系
- Clang:
- GCC: 10.2.0 ✅
- Visual C++: ??
参照
- P2422R1 Remove
nodiscardannotations from the standard library specification- C++26で
[[nodiscard]]指定が削除された
- C++26で