+ ~jthread()
+ {
+ if (joinable())
+ {
+ request_stop();
+ join();
+ }
+ }
+
+ jthread&
+ operator=(const jthread&) = delete;
+
+ jthread&
+ operator=(jthread&& __other) noexcept
+ {
+ std::jthread(std::move(__other)).swap(*this);
+ return *this;
+ }
+
+ void
+ swap(jthread& __other) noexcept
+ {
+ std::swap(_M_stop_source, __other._M_stop_source);
+ std::swap(_M_thread, __other._M_thread);
+ }
+
+ [[nodiscard]] bool
+ joinable() const noexcept
+ {
+ return _M_thread.joinable();
+ }
+
+ void
+ join()
+ {
+ _M_thread.join();
+ }
+
+ void
+ detach()
+ {
+ _M_thread.detach();
+ }
+
+ [[nodiscard]] id
+ get_id() const noexcept
+ {
+ return _M_thread.get_id();
+ }
+
+ [[nodiscard]] native_handle_type
+ native_handle()
+ {
+ return _M_thread.native_handle();
+ }
+
+ [[nodiscard]] static unsigned
+ hardware_concurrency() noexcept
+ {
+ return thread::hardware_concurrency();
+ }
+
+ [[nodiscard]] stop_source
+ get_stop_source() noexcept
+ {
+ return _M_stop_source;
+ }
+
+ [[nodiscard]] stop_token
+ get_stop_token() const noexcept
+ {
+ return _M_stop_source.get_token();
+ }
+
+ bool request_stop() noexcept
+ {
+ return _M_stop_source.request_stop();
+ }
+
+ friend void swap(jthread& __lhs, jthread& __rhs) noexcept
+ {
+ __lhs.swap(__rhs);
+ }
+
+ private:
+ template<typename _Callable, typename... _Args>
+ static thread
+ _S_create(stop_source& __ssrc, _Callable&& __f, _Args&&... __args)
+ {
+ if constexpr(is_invocable_v<decay_t<_Callable>, stop_token,
+ decay_t<_Args>...>)
+ return thread{std::forward<_Callable>(__f), __ssrc.get_token(),
+ std::forward<_Args>(__args)...};
+ else
+ {
+ static_assert(is_invocable_v<decay_t<_Callable>,
+ decay_t<_Args>...>,
+ "std::thread arguments must be invocable after"
+ " conversion to rvalues");
+ return thread{std::forward<_Callable>(__f),
+ std::forward<_Args>(__args)...};
+ }
+ }
+
+ stop_source _M_stop_source;
+ thread _M_thread;
+ };
+#endif // __cpp_lib_jthread
+
+ // @} group threads
+
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace
+#endif // C++11