[libc++] Implement `operator==` for `filesystem::space_info`
Implements part of P1614R2 "The Mothership has Landed"
Differential Revision: https://reviews.llvm.org/D130861
NOKEYCHECK=True
GitOrigin-RevId: 706b3951b38961ffa6581d446fee6664038caced
diff --git a/docs/Status/SpaceshipProjects.csv b/docs/Status/SpaceshipProjects.csv
index 8ba48bd..4ef0ca9 100644
--- a/docs/Status/SpaceshipProjects.csv
+++ b/docs/Status/SpaceshipProjects.csv
@@ -74,7 +74,7 @@
| `[time.zone.link.nonmembers] <https://wg21.link/time.zone.link.nonmembers>`_","| chrono::time_zone
| chrono::leap_second
| chrono::time_zone_link",A ``<chrono>`` implementation,Unassigned,|Not Started|
-| `[fs.filesystem.syn] <https://wg21.link/fs.filesystem.syn>`_,| `filesystem::space_info <https://reviews.llvm.org/D130861>`_,None,Adrian Vogelsgesang,|In Progress|
+| `[fs.filesystem.syn] <https://wg21.link/fs.filesystem.syn>`_,| `filesystem::space_info <https://reviews.llvm.org/D130861>`_,None,Adrian Vogelsgesang,|Complete|
| `[fs.path.nonmember] <https://wg21.link/fs.path.nonmember>`_,| `filesystem::path <https://reviews.llvm.org/D130859>`_,None,Adrian Vogelsgesang,|In Progress|
| `[fs.dir.entry.obs] <https://wg21.link/fs.dir.entry.obs>`_,| `filesystem::directory_entry <https://reviews.llvm.org/D130860>`_,None,Adrian Vogelsgesang,|In Progress|
| `[re.submatch.op] <https://wg21.link/re.submatch.op>`_,| sub_match,None,Mark de Wever,|In Progress|
diff --git a/include/__filesystem/space_info.h b/include/__filesystem/space_info.h
index d7dc03a..d0747e3 100644
--- a/include/__filesystem/space_info.h
+++ b/include/__filesystem/space_info.h
@@ -28,6 +28,10 @@
uintmax_t capacity;
uintmax_t free;
uintmax_t available;
+
+# if _LIBCPP_STD_VER > 17
+ friend _LIBCPP_HIDE_FROM_ABI bool operator==(const space_info&, const space_info&) = default;
+# endif
};
_LIBCPP_AVAILABILITY_FILESYSTEM_POP
diff --git a/include/filesystem b/include/filesystem
index 87de886..aa0cd56 100644
--- a/include/filesystem
+++ b/include/filesystem
@@ -64,6 +64,8 @@
uintmax_t capacity;
uintmax_t free;
uintmax_t available;
+
+ friend bool operator==(const space_info&, const space_info&) = default; // C++20
};
enum class file_type;
diff --git a/test/std/input.output/filesystems/fs.filesystem.synopsis/space_info.pass.cpp b/test/std/input.output/filesystems/fs.filesystem.synopsis/space_info.pass.cpp
new file mode 100644
index 0000000..9a9a93c
--- /dev/null
+++ b/test/std/input.output/filesystems/fs.filesystem.synopsis/space_info.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// <filesystem>
+
+// friend bool operator==(const space_info&, const space_info&);
+
+#include "filesystem_include.h"
+
+#include "test_macros.h"
+#include "test_comparisons.h"
+
+using namespace fs;
+
+constexpr bool test() {
+ assert(testEquality(space_info{1, 2, 3}, space_info{1, 2, 3}, true));
+ assert(testEquality(space_info{0, 2, 3}, space_info{1, 2, 3}, false));
+ assert(testEquality(space_info{1, 0, 3}, space_info{1, 2, 3}, false));
+ assert(testEquality(space_info{1, 2, 0}, space_info{1, 2, 3}, false));
+
+ return true;
+}
+
+int main(int, char**) {
+ using space_info = std::filesystem::space_info;
+
+ AssertEqualityAreNoexcept<space_info>();
+ AssertEqualityReturnBool<space_info>();
+
+ test();
+ static_assert(test());
+
+ return 0;
+}