[libcxx-commits] [PATCH] D130861: [libc++] Implement `operator==` for `filesystem::space_info`

Adrian Vogelsgesang via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Sun Jul 31 16:31:27 PDT 2022


avogelsgesang created this revision.
avogelsgesang added reviewers: ldionne, philnik, Mordante.
Herald added a project: All.
avogelsgesang requested review of this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.

Implements part of P1614R2 "The Mothership has Landed"


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D130861

Files:
  libcxx/docs/ReleaseNotes.rst
  libcxx/docs/Status/SpaceshipProjects.csv
  libcxx/include/__filesystem/space_info.h
  libcxx/test/std/input.output/filesystems/fs.filesystem.synopsis/space_info.pass.cpp


Index: libcxx/test/std/input.output/filesystems/fs.filesystem.synopsis/space_info.pass.cpp
===================================================================
--- /dev/null
+++ libcxx/test/std/input.output/filesystems/fs.filesystem.synopsis/space_info.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// 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() {
+  using space_info = std::filesystem::space_info;
+
+  assert(testOrder(space_info{1, 2, 3}, space_info{1, 2, 3}, std::strong_ordering::equal));
+  assert(testOrder(space_info{0, 2, 3}, space_info{1, 2, 3}, std::strong_ordering::less));
+  assert(testOrder(space_info{1, 0, 3}, space_info{1, 2, 3}, std::strong_ordering::less));
+  assert(testOrder(space_info{1, 2, 0}, space_info{1, 2, 3}, std::strong_ordering::less));
+  assert(testOrder(space_info{1, 2, 3}, space_info{0, 2, 3}, std::strong_ordering::greater));
+  assert(testOrder(space_info{1, 2, 3}, space_info{1, 0, 3}, std::strong_ordering::greater));
+  assert(testOrder(space_info{1, 2, 3}, space_info{1, 2, 0}, std::strong_ordering::greater));
+}
+
+int main(int, char**) {
+  using space_info = std::filesystem::space_info;
+  AssertOrderReturn<std::strong_ordering, space_info>();
+
+  test();
+  static_assert(test());
+
+  return 0;
+}
Index: libcxx/include/__filesystem/space_info.h
===================================================================
--- libcxx/include/__filesystem/space_info.h
+++ libcxx/include/__filesystem/space_info.h
@@ -28,6 +28,10 @@
   uintmax_t capacity;
   uintmax_t free;
   uintmax_t available;
+
+#  if _LIBCPP_STD_VER > 17
+  friend bool operator==(const space_info&, const space_info&) = default;
+#  endif
 };
 
 _LIBCPP_AVAILABILITY_FILESYSTEM_POP
Index: libcxx/docs/Status/SpaceshipProjects.csv
===================================================================
--- libcxx/docs/Status/SpaceshipProjects.csv
+++ libcxx/docs/Status/SpaceshipProjects.csv
@@ -73,6 +73,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,None,Adrian Vogelsgesang,|Done|
 | `[fs.path.nonmember] <https://wg21.link/fs.path.nonmember>`_,| filesystem::path,None,Unassigned,|Not Started|
 | `[fs.dir.entry.obs] <https://wg21.link/fs.dir.entry.obs>`_,| filesystem::directory_entry,None,Unassigned,|Not Started|
 | `[re.submatch.op] <https://wg21.link/re.submatch.op>`_,| sub_match,None,Unassigned,|Not Started|
Index: libcxx/docs/ReleaseNotes.rst
===================================================================
--- libcxx/docs/ReleaseNotes.rst
+++ libcxx/docs/ReleaseNotes.rst
@@ -41,6 +41,8 @@
 Improvements and New Features
 -----------------------------
 
+* Implemented `operator==` for `filesystem::space_info`
+
 Deprecations and Removals
 -------------------------
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D130861.448895.patch
Type: text/x-patch
Size: 3535 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220731/698f893f/attachment.bin>


More information about the libcxx-commits mailing list