diff --git a/libcxx/docs/Status/Cxx17Issues.csv b/libcxx/docs/Status/Cxx17Issues.csv --- a/libcxx/docs/Status/Cxx17Issues.csv +++ b/libcxx/docs/Status/Cxx17Issues.csv @@ -316,3 +316,5 @@ "`2901 `__","Variants cannot properly support allocators","Toronto","|Complete|","" "`2955 `__","``to_chars / from_chars``\ depend on ``std::string``\ ","Toronto","Resolved by `P0682R1 `__","" "`2956 `__","``filesystem::canonical()``\ still defined in terms of ``absolute(p, base)``\ ","Toronto","|Complete|","" +"","","","","" +"`3657 `__","``std::hash`` is not enabled","","|Complete|","" \ No newline at end of file diff --git a/libcxx/include/__filesystem/path.h b/libcxx/include/__filesystem/path.h --- a/libcxx/include/__filesystem/path.h +++ b/libcxx/include/__filesystem/path.h @@ -1019,6 +1019,21 @@ _LIBCPP_END_NAMESPACE_FILESYSTEM +_LIBCPP_AVAILABILITY_FILESYSTEM_PUSH + +_LIBCPP_BEGIN_NAMESPACE_STD + +template <> +struct _LIBCPP_TEMPLATE_VIS hash<_VSTD_FS ::path> : public unary_function<_VSTD_FS ::path, size_t> { + + _LIBCPP_INLINE_VISIBILITY + size_t operator()(const _VSTD_FS ::path& __val) const _NOEXCEPT { return _VSTD_FS ::hash_value(__val); } +}; + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_AVAILABILITY_FILESYSTEM_POP + #endif // _LIBCPP_CXX03_LANG #endif // _LIBCPP___FILESYSTEM_PATH_H diff --git a/libcxx/include/filesystem b/libcxx/include/filesystem --- a/libcxx/include/filesystem +++ b/libcxx/include/filesystem @@ -237,6 +237,9 @@ template <> inline constexpr bool std::ranges::enable_view = true; +template <> +struct std::hash; + */ #include <__assert> // all public C++ headers provide the assertion handler diff --git a/libcxx/test/std/input.output/filesystems/class.path/path.member/path.compare.pass.cpp b/libcxx/test/std/input.output/filesystems/class.path/path.member/path.compare.pass.cpp --- a/libcxx/test/std/input.output/filesystems/class.path/path.member/path.compare.pass.cpp +++ b/libcxx/test/std/input.output/filesystems/class.path/path.member/path.compare.pass.cpp @@ -9,6 +9,7 @@ // UNSUPPORTED: c++03 // +// // class path @@ -24,9 +25,16 @@ // bool operator>=(path const&, path const&) noexcept; // // size_t hash_value(path const&) noexcept; - +// +// template +// struct hash +// : public unary_function +// { +// size_t operator()(T val) const; +// }; #include "filesystem_include.h" +#include #include #include #include @@ -131,9 +139,13 @@ auto h1 = hash_value(p1); auto h2 = hash_value(p2); assert((h1 == h2) == (p1 == p2)); + assert(h1 == std::hash()(p1)); + assert(h2 == std::hash()(p2)); // check signature ASSERT_SAME_TYPE(size_t, decltype(hash_value(p1))); ASSERT_NOEXCEPT(hash_value(p1)); + ASSERT_SAME_TYPE(size_t, decltype(std::hash()(p1))); + ASSERT_NOEXCEPT(std::hash()(p1)); } } } diff --git a/libcxx/test/std/input.output/filesystems/class.path/path.nonmember/hash_value_tested_elswhere.pass.cpp b/libcxx/test/std/input.output/filesystems/class.path/path.nonmember/enabled_hash.pass.cpp rename from libcxx/test/std/input.output/filesystems/class.path/path.nonmember/hash_value_tested_elswhere.pass.cpp rename to libcxx/test/std/input.output/filesystems/class.path/path.nonmember/enabled_hash.pass.cpp --- a/libcxx/test/std/input.output/filesystems/class.path/path.nonmember/hash_value_tested_elswhere.pass.cpp +++ b/libcxx/test/std/input.output/filesystems/class.path/path.nonmember/enabled_hash.pass.cpp @@ -8,8 +8,20 @@ // UNSUPPORTED: c++03 -// The "hash_value" function is tested as part of [path.compare] -// in class.path/path.members/path.compare.pass.cpp +// + +// Test that provides all of the arithmetic, enum, and pointer +// hash specializations. + +#include + +#include "poisoned_hash_helper.h" + +#include "test_macros.h" + int main(int, char**) { + test_library_hash_specializations_available(); + { test_hash_enabled_for_type(); } + return 0; } diff --git a/libcxx/test/std/input.output/filesystems/class.path/path.nonmember/hash_value_tested_elswhere.pass.cpp b/libcxx/test/std/input.output/filesystems/class.path/path.nonmember/hash_tested_elswhere.pass.cpp rename from libcxx/test/std/input.output/filesystems/class.path/path.nonmember/hash_value_tested_elswhere.pass.cpp rename to libcxx/test/std/input.output/filesystems/class.path/path.nonmember/hash_tested_elswhere.pass.cpp --- a/libcxx/test/std/input.output/filesystems/class.path/path.nonmember/hash_value_tested_elswhere.pass.cpp +++ b/libcxx/test/std/input.output/filesystems/class.path/path.nonmember/hash_tested_elswhere.pass.cpp @@ -8,8 +8,8 @@ // UNSUPPORTED: c++03 -// The "hash_value" function is tested as part of [path.compare] -// in class.path/path.members/path.compare.pass.cpp -int main(int, char**) { - return 0; -} +// The "hash_value" function and std::hash specialization are +// tested as part of [path.compare] in +// class.path/path.members/path.compare.pass.cpp + +int main(int, char**) { return 0; }