1414#include <tuple>
1515#include <xthreads.h>
1616#if _HAS_CXX20
17+ #include <compare>
1718#include <stop_token>
1819#endif // _HAS_CXX20
1920
@@ -215,7 +216,11 @@ private:
215216 friend thread::id thread::get_id() const noexcept;
216217 friend thread::id this_thread::get_id() noexcept;
217218 friend bool operator==(thread::id _Left, thread::id _Right) noexcept;
219+ #if _HAS_CXX20
220+ friend strong_ordering operator<=>(thread::id _Left, thread::id _Right) noexcept;
221+ #else // ^^^ _HAS_CXX20 / !_HAS_CXX20 vvv
218222 friend bool operator<(thread::id _Left, thread::id _Right) noexcept;
223+ #endif // !_HAS_CXX20
219224 template <class _Ch, class _Tr>
220225 friend basic_ostream<_Ch, _Tr>& operator<<(basic_ostream<_Ch, _Tr>& _Str, thread::id _Id);
221226 friend hash<thread::id>;
@@ -237,6 +242,11 @@ _NODISCARD inline bool operator==(thread::id _Left, thread::id _Right) noexcept
237242 return _Left._Id == _Right._Id;
238243}
239244
245+ #if _HAS_CXX20
246+ _NODISCARD inline strong_ordering operator<=>(thread::id _Left, thread::id _Right) noexcept {
247+ return _Left._Id <=> _Right._Id;
248+ }
249+ #else // ^^^ _HAS_CXX20 / !_HAS_CXX20 vvv
240250_NODISCARD inline bool operator!=(thread::id _Left, thread::id _Right) noexcept {
241251 return !(_Left == _Right);
242252}
@@ -256,6 +266,7 @@ _NODISCARD inline bool operator>(thread::id _Left, thread::id _Right) noexcept {
256266_NODISCARD inline bool operator>=(thread::id _Left, thread::id _Right) noexcept {
257267 return !(_Left < _Right);
258268}
269+ #endif // !_HAS_CXX20
259270
260271template <class _Ch, class _Tr>
261272basic_ostream<_Ch, _Tr>& operator<<(basic_ostream<_Ch, _Tr>& _Str, thread::id _Id) {
0 commit comments