[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 Aug 7 07:06:21 PDT 2022


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

Remove debug include


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/include/filesystem
  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,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;
+}
Index: libcxx/include/filesystem
===================================================================
--- libcxx/include/filesystem
+++ libcxx/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;
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 _LIBCPP_HIDE_FROM_ABI 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
@@ -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|


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D130861.450620.patch
Type: text/x-patch
Size: 3516 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220807/fec7c2f4/attachment.bin>


More information about the libcxx-commits mailing list