int main()
{
auto token = std::stop_token{};
auto thrd = std::jthread{[](std::stop_token){}, token};
assert(thrd.get_stop_token() == token); // surprise
return EXIT_SUCCESS;
}
Just small question regarding the intended way the jthread ctor is used, because that was shown to me today as an alternative and valid way to use a jthread. I think that should not be allowed or otherwise the explicitly supplied stop_token should be copied/moved into the jthread so that the assertion holds. Or else the result of get_stop_token() may "surprise" when used IMHO.
Just small question regarding the intended way the jthread ctor is used, because that was shown to me today as an alternative and valid way to use a jthread. I think that should not be allowed or otherwise the explicitly supplied stop_token should be copied/moved into the jthread so that the assertion holds. Or else the result of get_stop_token() may "surprise" when used IMHO.