[libcxx-commits] [libcxx] [libc++][chrono] P2592R3: Hashing for chrono (PR #165132)
A. Jiang via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Nov 26 00:10:15 PST 2025
================
@@ -92,6 +94,15 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr day& day::operator-=(const days& __dd) no
} // namespace chrono
+# if _LIBCPP_STD_VER >= 26
+
+template <>
+struct hash<chrono::day> {
+ _LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::day& __d) noexcept { return static_cast<unsigned>(__d); }
----------------
frederick-vs-ja wrote:
Per some recent decisions, we should add `[[nodiscard]]` to all new `hash::operator()`s. And then add test cases to `libcxx/test/libcxx/time/time.hash/nodiscard.verify.cpp`.
https://github.com/llvm/llvm-project/pull/165132
More information about the libcxx-commits
mailing list