38#ifdef __cpp_lib_jthread
44 bool stop_requested()
const {
return false; }
50 bool request_stop()
noexcept {
return false; }
51 bool stop_requested()
const noexcept {
return false; }
57 template<
typename F,
typename... Args>
58 explicit jthread(F&& f, Args&&... args)
59 : std::thread([](std::decay_t<F> f, std::decay_t<Args>... args) {
60 if constexpr (std::is_invocable_v<std::decay_t<F>,
stop_token, std::decay_t<Args>...>) {
63 f(std::move(args)...);
65 }, std::forward<F>(f), std::forward<Args>(args)...) {}
68 if (joinable()) join();
69 std::thread::operator=(std::move(other));
73 if (joinable()) join();
75 void request_stop()
noexcept {}
82#if defined(__cpp_lib_ranges_contains) && __cpp_lib_ranges_contains >= 202207L
83 using std::ranges::contains;
85 template<
typename R,
typename T>
86 constexpr bool contains(R&& r,
const T& value) {
87 return std::ranges::find(r, value) != std::ranges::end(r);