- thread[meta header]
- std[meta namespace]
- jthread[meta class]
- function[meta id-type]
- cpp20[meta cpp]
[[nodiscard]] bool joinable() const noexcept; // (1) C++20
bool joinable() const noexcept; // (1) C++26jthreadオブジェクトがスレッドと関連付けられているか否か取得する。
return get_id() != id();- get_id()[link get_id.md]
- id[link /reference/thread/thread/id.md]
送出しない。
#include <cassert>
#include <thread>
int main()
{
std::jthread jt([]{ /*...*/ });
assert(jt.joinable());
jt.join();
assert(!jt.joinable());
}- joinable()[color ff0000]
- C++20
- Clang:
- GCC: 10.2.0 [mark verified]
- Visual C++: ??
- P2422R1 Remove
nodiscardannotations from the standard library specification- C++26で
[[nodiscard]]指定が削除された
- C++26で