This DR was approved at the February 2022 plenary.
libstdc++-v3/ChangeLog:
* include/bits/fs_path.h (hash<filesystem::path>): Define.
* testsuite/27_io/filesystem/path/nonmember/hash_value.cc:
Check std::hash specialization.
/// @endcond
+// _GLIBCXX_RESOLVE_LIB_DEFECTS
+// 3657. std::hash<std::filesystem::path> is not enabled
+template<>
+ struct hash<filesystem::path>
+ {
+ size_t
+ operator()(const filesystem::path& __p) const noexcept
+ { return filesystem::hash_value(__p); }
+ };
+
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
}
}
+void
+test03()
+{
+ std::hash<path> h;
+ // LWG 3657. std::hash<std::filesystem::path> is not enabled
+ for (const path p : __gnu_test::test_paths)
+ VERIFY( h(p) == hash_value(p) );
+}
+
int
main()
{
test01();
test02();
+ test03();
}