- stop_token[meta header]
- std[meta namespace]
- class[meta id-type]
- cpp20[meta cpp]
namespace std {
struct nostopstate_t {
explicit nostopstate_t() = default;
};
inline constexpr nostopstate_t nostopstate{};
}
nostopstate_t
型とその値nostopstate
は、停止状態を扱わないstop_source
を構築するためのタグである。
stop_source
クラスのコンストラクタにnostopstate
を渡すと、そのstop_source
は停止要求を扱うためのリソースを確保せず、停止要求を作成したりstop_token
クラスと停止状態を共有したりできない状態になる。
#include <cassert>
#include <stop_token>
int main()
{
std::stop_source ss1;
std::stop_source ss2(std::nostopstate);
assert(ss1.stop_possible() == true);
assert(ss2.stop_possible() == false);
std::stop_token st1 = ss1.get_token();
std::stop_token st2 = ss2.get_token();
assert(st1.stop_possible() == true);
assert(st2.stop_possible() == false);
}
- std::nostopstate[color ff0000]
- std::stop_token[link stop_token.md]
- std::stop_source[link stop_source.md]
- stop_possible()[link stop_token/stop_possible.md]
- get_token()[link stop_source/get_token.md]
- C++20
- Clang: ??
- GCC: ??
- ICC: ??
- Visual C++: ??