2626#include <xfilesystem_abi.h>
2727#include <xstring>
2828
29+ #if _HAS_CXX20
30+ #include <compare>
31+ #endif // _HAS_CXX20
32+
2933#pragma pack(push, _CRT_PACKING)
3034#pragma warning(push, _STL_WARNING_LEVEL)
3135#pragma warning(disable : _STL_DISABLED_WARNINGS)
@@ -1399,6 +1403,11 @@ namespace filesystem {
13991403 return _Left.compare(_Right) == 0;
14001404 }
14011405
1406+ #if _HAS_CXX20
1407+ _NODISCARD friend strong_ordering operator<=>(const path& _Left, const path& _Right) noexcept {
1408+ return _Left.compare(_Right) <=> 0;
1409+ }
1410+ #else // ^^^ _HAS_CXX20 / !_HAS_CXX20 vvv
14021411 _NODISCARD friend bool operator!=(const path& _Left, const path& _Right) noexcept {
14031412 return _Left.compare(_Right) != 0;
14041413 }
@@ -1418,6 +1427,7 @@ namespace filesystem {
14181427 _NODISCARD friend bool operator>=(const path& _Left, const path& _Right) noexcept {
14191428 return _Left.compare(_Right) >= 0;
14201429 }
1430+ #endif // !_HAS_CXX20
14211431
14221432 _NODISCARD friend path operator/(const path& _Left, const path& _Right) { // append a pair of paths together
14231433 return path(_Left) /= _Right;
@@ -1967,6 +1977,12 @@ namespace filesystem {
19671977 return _Myperms;
19681978 }
19691979
1980+ #if _HAS_CXX20
1981+ _NODISCARD friend bool operator==(const file_status& _Lhs, const file_status& _Rhs) noexcept {
1982+ return _Lhs._Myftype == _Rhs._Myftype && _Lhs._Myperms == _Rhs._Myperms;
1983+ }
1984+ #endif // _HAS_CXX20
1985+
19701986 void _Refresh(const __std_win_error _Error, const __std_fs_stats& _Stats) noexcept {
19711987 if (_Error == __std_win_error::_Success) {
19721988 const auto _Attrs = _Stats._Attributes;
@@ -2445,18 +2461,23 @@ namespace filesystem {
24452461 return _Result._Status;
24462462 }
24472463
2448- _NODISCARD bool operator<(const directory_entry& _Rhs) const noexcept {
2449- return _Path < _Rhs._Path;
2450- }
2451-
24522464 _NODISCARD bool operator==(const directory_entry& _Rhs) const noexcept {
24532465 return _Path == _Rhs._Path;
24542466 }
24552467
2468+ #if _HAS_CXX20
2469+ _NODISCARD strong_ordering operator<=>(const directory_entry& _Rhs) const noexcept {
2470+ return _Path <=> _Rhs._Path;
2471+ }
2472+ #else // ^^^ _HAS_CXX20 / !_HAS_CXX20 vvv
24562473 _NODISCARD bool operator!=(const directory_entry& _Rhs) const noexcept {
24572474 return _Path != _Rhs._Path;
24582475 }
24592476
2477+ _NODISCARD bool operator<(const directory_entry& _Rhs) const noexcept {
2478+ return _Path < _Rhs._Path;
2479+ }
2480+
24602481 _NODISCARD bool operator<=(const directory_entry& _Rhs) const noexcept {
24612482 return _Path <= _Rhs._Path;
24622483 }
@@ -2468,6 +2489,7 @@ namespace filesystem {
24682489 _NODISCARD bool operator>=(const directory_entry& _Rhs) const noexcept {
24692490 return _Path >= _Rhs._Path;
24702491 }
2492+ #endif // !_HAS_CXX20
24712493
24722494 // [fs.dir.entry.io], inserter
24732495 template <class _Elem, class _Traits>
@@ -3649,6 +3671,10 @@ namespace filesystem {
36493671 uintmax_t capacity;
36503672 uintmax_t free;
36513673 uintmax_t available;
3674+
3675+ #if _HAS_CXX20
3676+ _NODISCARD friend constexpr bool operator==(const space_info&, const space_info&) noexcept = default;
3677+ #endif // _HAS_CXX20
36523678 };
36533679
36543680 _NODISCARD inline space_info space(const path& _Target) {
0 commit comments