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

Adrian Vogelsgesang via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Mon Aug 1 14:59:17 PDT 2022


avogelsgesang updated this revision to Diff 449139.
avogelsgesang added a comment.

update based on first feedback on https://reviews.llvm.org/D130852


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D130861/new/

https://reviews.llvm.org/D130861

Files:
  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,44 @@
+//===----------------------------------------------------------------------===//
+//
+// 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;
+
+  AssertOrderAreNoexcept<space_info>();
+  AssertOrderReturn<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|


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D130861.449139.patch
Type: text/x-patch
Size: 3247 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220801/4aa979f7/attachment-0001.bin>


More information about the libcxx-commits mailing list