[libcxx-commits] [PATCH] D143452: [libc++] Implement LWG3657 std::hash<filesystem::path>

Nikolas Klauser via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue Feb 7 02:50:00 PST 2023


philnik accepted this revision.
philnik added a comment.
This revision is now accepted and ready to land.

LGTM % nits.



================
Comment at: libcxx/include/__filesystem/path.h:1092
+template <>
+struct hash<_VSTD_FS::path> : __unary_function<_VSTD_FS::path, size_t> {
+  _LIBCPP_HIDE_FROM_ABI size_t operator()(_VSTD_FS::path const& __p) const noexcept {
----------------
I don't think we have to inherit from `unary_function` here, and I don't really see a point if we don't have to.


================
Comment at: libcxx/test/std/input.output/filesystems/class.path/path.member/path.compare.pass.cpp:138-139
+    { // check std::hash
+      auto h1 = std::hash<std::filesystem::path>()(p1);
+      auto h2 = std::hash<std::filesystem::path>()(p2);
+      assert((h1 == h2) == (p1 == p2));
----------------
Unfortunatley, we provide `std::filesystem` as an extension in C++11 and C++14 under `std::__fs::filesystem`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143452



More information about the libcxx-commits mailing list