[libc++][chrono] P2592R3: Hashing for chrono (#165132)

This commit is contained in:
Rafail Shakhin ogly 2026-01-03 05:32:14 +03:00 committed by GitHub
parent e9b2b21f74
commit ec7b63771c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
20 changed files with 370 additions and 1 deletions

View File

@ -38,6 +38,7 @@ What's New in Libc++ 22.0.0?
Implemented Papers
------------------
- P2592R3: Hashing support for ``std::chrono`` value classes (`Github <https://llvm.org/PR105358>`__)
- P2321R2: ``zip`` (`Github <https://llvm.org/PR105169>`__) (The paper is partially implemented. ``zip_transform_view``,
``adjacent_view``, and ``adjacent_transform_view`` are implemented in this release)
- P2988R12: ``std::optional<T&>`` (`Github <https://llvm.org/PR148131>`__)

View File

@ -1,6 +1,6 @@
"Paper #","Paper Name","Meeting","Status","First released version","GitHub issue","Notes"
"`P2497R0 <https://wg21.link/P2497R0>`__","Testing for success or failure of ``<charconv>`` functions","2023-06 (Varna)","|Complete|","18","`#105357 <https://github.com/llvm/llvm-project/issues/105357>`__",""
"`P2592R3 <https://wg21.link/P2592R3>`__","Hashing support for ``std::chrono`` value classes","2023-06 (Varna)","","","`#105358 <https://github.com/llvm/llvm-project/issues/105358>`__",""
"`P2592R3 <https://wg21.link/P2592R3>`__","Hashing support for ``std::chrono`` value classes","2023-06 (Varna)","|Complete|","22","`#105358 <https://github.com/llvm/llvm-project/issues/105358>`__",""
"`P2587R3 <https://wg21.link/P2587R3>`__","``to_string`` or not ``to_string``","2023-06 (Varna)","","","`#105359 <https://github.com/llvm/llvm-project/issues/105359>`__",""
"`P2562R1 <https://wg21.link/P2562R1>`__","``constexpr`` Stable Sorting","2023-06 (Varna)","|Complete|","21","`#105360 <https://github.com/llvm/llvm-project/issues/105360>`__",""
"`P2545R4 <https://wg21.link/P2545R4>`__","Read-Copy Update (RCU)","2023-06 (Varna)","","","`#105361 <https://github.com/llvm/llvm-project/issues/105361>`__",""

1 Paper # Paper Name Meeting Status First released version GitHub issue Notes
2 `P2497R0 <https://wg21.link/P2497R0>`__ Testing for success or failure of ``<charconv>`` functions 2023-06 (Varna) |Complete| 18 `#105357 <https://github.com/llvm/llvm-project/issues/105357>`__
3 `P2592R3 <https://wg21.link/P2592R3>`__ Hashing support for ``std::chrono`` value classes 2023-06 (Varna) |Complete| 22 `#105358 <https://github.com/llvm/llvm-project/issues/105358>`__
4 `P2587R3 <https://wg21.link/P2587R3>`__ ``to_string`` or not ``to_string`` 2023-06 (Varna) `#105359 <https://github.com/llvm/llvm-project/issues/105359>`__
5 `P2562R1 <https://wg21.link/P2562R1>`__ ``constexpr`` Stable Sorting 2023-06 (Varna) |Complete| 21 `#105360 <https://github.com/llvm/llvm-project/issues/105360>`__
6 `P2545R4 <https://wg21.link/P2545R4>`__ Read-Copy Update (RCU) 2023-06 (Varna) `#105361 <https://github.com/llvm/llvm-project/issues/105361>`__

View File

@ -13,6 +13,8 @@
#include <__chrono/duration.h>
#include <__compare/ordering.h>
#include <__config>
#include <__cstddef/size_t.h>
#include <__functional/hash.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@ -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); }
};
# endif // _LIBCPP_STD_VER >= 26
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_STD_VER >= 20

View File

@ -13,6 +13,8 @@
#include <__compare/ordering.h>
#include <__compare/three_way_comparable.h>
#include <__config>
#include <__cstddef/size_t.h>
#include <__functional/hash.h>
#include <__type_traits/common_type.h>
#include <__type_traits/enable_if.h>
#include <__type_traits/is_convertible.h>
@ -538,6 +540,18 @@ using namespace literals::chrono_literals;
#endif // _LIBCPP_STD_VER >= 14
#if _LIBCPP_STD_VER >= 26
template <class _Rep, class _Period>
requires __has_enabled_hash<_Rep>::value
struct hash<chrono::duration<_Rep, _Period>> {
_LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::duration<_Rep, _Period>& __d) {
return hash<_Rep>{}(__d.count());
}
};
#endif // _LIBCPP_STD_VER >= 26
_LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS

View File

@ -22,6 +22,8 @@
# include <__compare/ordering.h>
# include <__compare/three_way_comparable.h>
# include <__config>
# include <__cstddef/size_t.h>
# include <__functional/hash.h>
# include <__utility/private_constructor_tag.h>
# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@ -122,6 +124,17 @@ private:
} // namespace chrono
# if _LIBCPP_STD_VER >= 26
template <>
struct hash<chrono::leap_second> {
_LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::leap_second& __lp) noexcept {
return std::__hash_combine(hash<chrono::sys_seconds>{}(__lp.date()), hash<chrono::seconds>{}(__lp.value()));
}
};
# endif // _LIBCPP_STD_VER >= 26
# endif // _LIBCPP_STD_VER >= 20
_LIBCPP_END_NAMESPACE_STD

View File

@ -13,6 +13,8 @@
#include <__chrono/duration.h>
#include <__compare/ordering.h>
#include <__config>
#include <__cstddef/size_t.h>
#include <__functional/hash.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@ -108,6 +110,17 @@ inline constexpr month December{12};
} // namespace chrono
# if _LIBCPP_STD_VER >= 26
template <>
struct hash<chrono::month> {
_LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::month& __m) noexcept {
return static_cast<unsigned>(__m);
}
};
# endif // _LIBCPP_STD_VER >= 26
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_STD_VER >= 20

View File

@ -13,6 +13,8 @@
#include <__chrono/month.h>
#include <__chrono/weekday.h>
#include <__config>
#include <__cstddef/size_t.h>
#include <__functional/hash.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@ -98,6 +100,26 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr month_weekday_last operator/(const weekda
}
} // namespace chrono
# if _LIBCPP_STD_VER >= 26
template <>
struct hash<chrono::month_weekday> {
_LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::month_weekday& __mw) noexcept {
return std::__hash_combine(
hash<chrono::month>{}(__mw.month()), hash<chrono::weekday_indexed>{}(__mw.weekday_indexed()));
}
};
template <>
struct hash<chrono::month_weekday_last> {
_LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::month_weekday_last& __mwl) noexcept {
return std::__hash_combine(
hash<chrono::month>{}(__mwl.month()), hash<chrono::weekday_last>{}(__mwl.weekday_last()));
}
};
# endif // _LIBCPP_STD_VER >= 26
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_STD_VER >= 20

View File

@ -15,6 +15,8 @@
#include <__chrono/month.h>
#include <__compare/ordering.h>
#include <__config>
#include <__cstddef/size_t.h>
#include <__functional/hash.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@ -126,6 +128,24 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr month_day_last operator/(last_spec, int _
} // namespace chrono
# if _LIBCPP_STD_VER >= 26
template <>
struct hash<chrono::month_day> {
_LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::month_day& __md) noexcept {
return std::__hash_combine(hash<chrono::month>{}(__md.month()), hash<chrono::day>{}(__md.day()));
}
};
template <>
struct hash<chrono::month_day_last> {
_LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::month_day_last& __mdl) noexcept {
return hash<chrono::month>{}(__mdl.month());
}
};
# endif // _LIBCPP_STD_VER >= 26
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_STD_VER >= 20

View File

@ -14,6 +14,8 @@
#include <__compare/ordering.h>
#include <__compare/three_way_comparable.h>
#include <__config>
#include <__cstddef/size_t.h>
#include <__functional/hash.h>
#include <__type_traits/common_type.h>
#include <__type_traits/enable_if.h>
#include <__type_traits/is_convertible.h>
@ -224,6 +226,18 @@ operator-(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock,
} // namespace chrono
#if _LIBCPP_STD_VER >= 26
template <class _Clock, class _Duration>
requires __has_enabled_hash<_Duration>::value
struct hash<chrono::time_point<_Clock, _Duration>> {
_LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::time_point<_Clock, _Duration>& __tp) {
return hash<_Duration>{}(__tp.time_since_epoch());
}
};
#endif // _LIBCPP_STD_VER >= 26
_LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS

View File

@ -15,6 +15,8 @@
#include <__chrono/system_clock.h>
#include <__chrono/time_point.h>
#include <__config>
#include <__cstddef/size_t.h>
#include <__functional/hash.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@ -160,6 +162,29 @@ inline constexpr weekday Saturday{6};
} // namespace chrono
# if _LIBCPP_STD_VER >= 26
template <>
struct hash<chrono::weekday> {
_LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::weekday& __w) noexcept { return __w.c_encoding(); }
};
template <>
struct hash<chrono::weekday_indexed> {
_LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::weekday_indexed& __wi) noexcept {
return std::__hash_combine(hash<chrono::weekday>{}(__wi.weekday()), __wi.index());
}
};
template <>
struct hash<chrono::weekday_last> {
_LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::weekday_last& __wl) noexcept {
return hash<chrono::weekday>{}(__wl.weekday());
}
};
# endif // _LIBCPP_STD_VER >= 26
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_STD_VER >= 20

View File

@ -13,6 +13,8 @@
#include <__chrono/duration.h>
#include <__compare/ordering.h>
#include <__config>
#include <__cstddef/size_t.h>
#include <__functional/hash.h>
#include <limits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@ -109,6 +111,15 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool year::ok() const noexcept {
} // namespace chrono
# if _LIBCPP_STD_VER >= 26
template <>
struct hash<chrono::year> {
_LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::year& __y) noexcept { return static_cast<int>(__y); }
};
# endif // _LIBCPP_STD_VER >= 26
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_STD_VER >= 20

View File

@ -15,6 +15,8 @@
#include <__chrono/year.h>
#include <__compare/ordering.h>
#include <__config>
#include <__cstddef/size_t.h>
#include <__functional/hash.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@ -116,6 +118,17 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr year_month& year_month::operator-=(const
} // namespace chrono
# if _LIBCPP_STD_VER >= 26
template <>
struct hash<chrono::year_month> {
_LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::year_month& __ym) noexcept {
return std::__hash_combine(hash<chrono::year>{}(__ym.year()), hash<chrono::month>{}(__ym.month()));
}
};
# endif // _LIBCPP_STD_VER >= 26
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_STD_VER >= 20

View File

@ -21,6 +21,8 @@
#include <__chrono/year_month.h>
#include <__compare/ordering.h>
#include <__config>
#include <__cstddef/size_t.h>
#include <__functional/hash.h>
#include <limits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@ -330,6 +332,27 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr bool year_month_day::ok() const noexcept
} // namespace chrono
# if _LIBCPP_STD_VER >= 26
template <>
struct hash<chrono::year_month_day> {
_LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::year_month_day& __ymd) noexcept {
return std::__hash_combine(
hash<chrono::year>{}(__ymd.year()),
std::__hash_combine(hash<chrono::month>{}(__ymd.month()), hash<chrono::day>{}(__ymd.day())));
}
};
template <>
struct hash<chrono::year_month_day_last> {
_LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::year_month_day_last& __ymdl) noexcept {
return std::__hash_combine(
hash<chrono::year>{}(__ymdl.year()), hash<chrono::month_day_last>{}(__ymdl.month_day_last()));
}
};
# endif // _LIBCPP_STD_VER >= 26
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_STD_VER >= 20

View File

@ -22,6 +22,8 @@
#include <__chrono/year_month.h>
#include <__chrono/year_month_day.h>
#include <__config>
#include <__cstddef/size_t.h>
#include <__functional/hash.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@ -280,6 +282,30 @@ year_month_weekday_last::operator-=(const years& __dy) noexcept {
} // namespace chrono
# if _LIBCPP_STD_VER >= 26
template <>
struct hash<chrono::year_month_weekday> {
_LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::year_month_weekday& __ymw) noexcept {
return std::__hash_combine(
hash<chrono::year>{}(__ymw.year()),
std::__hash_combine(
hash<chrono::month>{}(__ymw.month()), hash<chrono::weekday_indexed>{}(__ymw.weekday_indexed())));
}
};
template <>
struct hash<chrono::year_month_weekday_last> {
_LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::year_month_weekday_last& __ymwl) noexcept {
return std::__hash_combine(
hash<chrono::year>{}(__ymwl.year()),
std::__hash_combine(
hash<chrono::month>{}(__ymwl.month()), hash<chrono::weekday_last>{}(__ymwl.weekday_last())));
}
};
# endif // _LIBCPP_STD_VER >= 26
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_STD_VER >= 20

View File

@ -24,6 +24,8 @@
# include <__chrono/tzdb_list.h>
# include <__concepts/constructible.h>
# include <__config>
# include <__cstddef/size_t.h>
# include <__functional/hash.h>
# include <__type_traits/common_type.h>
# include <__type_traits/conditional.h>
# include <__type_traits/remove_cvref.h>
@ -216,6 +218,19 @@ operator==(const zoned_time<_Duration1, _TimeZonePtr>& __lhs, const zoned_time<_
} // namespace chrono
# if _LIBCPP_STD_VER >= 26
template <class _Duration, class _TimeZonePtr>
requires __has_enabled_hash<_Duration>::value && __has_enabled_hash<_TimeZonePtr>::value
struct hash<chrono::zoned_time<_Duration, _TimeZonePtr>> {
_LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::zoned_time<_Duration, _TimeZonePtr>& __zt) {
return std::__hash_combine(
hash<chrono::sys_time<_Duration>>{}(__zt.get_sys_time()), hash<_TimeZonePtr>{}(__zt.get_time_zone()));
}
};
# endif // _LIBCPP_STD_VER >= 26
# endif // _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM &&
// _LIBCPP_HAS_LOCALIZATION

View File

@ -1038,6 +1038,49 @@ constexpr chrono::year operator ""y(unsigned lo
} // chrono_literals
} // literals
namespace std {
template<class T>
struct hash; // C++26
template<class Rep, class Period>
struct hash<chrono::duration<Rep, Period>>; // C++26
template<class Clock, class Duration>
struct hash<chrono::time_point<Clock, Duration>>; // C++26
template<>
struct hash<chrono::day>; // C++26
template<>
struct hash<chrono::month>; // C++26
template<>
struct hash<chrono::year>; // C++26
template<>
struct hash<chrono::weekday>; // C++26
template<>
struct hash<chrono::weekday_indexed>; // C++26
template<>
struct hash<chrono::weekday_last>; // C++26
template<>
struct hash<chrono::month_day>; // C++26
template<>
struct hash<chrono::month_day_last>; // C++26
template<>
struct hash<chrono::month_weekday>; // C++26
template<>
struct hash<chrono::month_weekday_last>; // C++26
template<>
struct hash<chrono::year_month>; // C++26
template<>
struct hash<chrono::year_month_day>; // C++26
template<>
struct hash<chrono::year_month_day_last>; // C++26
template<>
struct hash<chrono::year_month_weekday>; // C++26
template<>
struct hash<chrono::year_month_weekday_last>; // C++26
template<class Duration, class TimeZonePtr>
struct hash<chrono::zoned_time<Duration, TimeZonePtr>>; // C++26
template<>
struct hash<chrono::leap_second>; // C++26
} // namespace std
} // std
*/

View File

@ -284,6 +284,10 @@ export namespace std {
} // namespace chrono
#if _LIBCPP_STD_VER >= 26
using std::hash;
#endif
} // namespace std
export namespace std::inline literals::inline chrono_literals {
// [time.duration.literals], suffixes for duration literals

View File

@ -669,6 +669,7 @@ memory_resource cerrno
memory_resource climits
memory_resource compare
memory_resource cstdint
memory_resource cstring
memory_resource ctime
memory_resource limits
memory_resource ratio
@ -678,6 +679,7 @@ mutex cerrno
mutex climits
mutex compare
mutex cstdint
mutex cstring
mutex ctime
mutex limits
mutex ratio
@ -877,6 +879,7 @@ set version
shared_mutex cerrno
shared_mutex climits
shared_mutex cstdint
shared_mutex cstring
shared_mutex ctime
shared_mutex limits
shared_mutex ratio

1 algorithm cctype
669 memory_resource climits
670 memory_resource compare
671 memory_resource cstdint
672 memory_resource cstring
673 memory_resource ctime
674 memory_resource limits
675 memory_resource ratio
679 mutex climits
680 mutex compare
681 mutex cstdint
682 mutex cstring
683 mutex ctime
684 mutex limits
685 mutex ratio
879 shared_mutex cerrno
880 shared_mutex climits
881 shared_mutex cstdint
882 shared_mutex cstring
883 shared_mutex ctime
884 shared_mutex limits
885 shared_mutex ratio

View File

@ -653,6 +653,7 @@ memory_resource cerrno
memory_resource climits
memory_resource compare
memory_resource cstdint
memory_resource cstring
memory_resource ctime
memory_resource limits
memory_resource ratio
@ -662,6 +663,7 @@ mutex cerrno
mutex climits
mutex compare
mutex cstdint
mutex cstring
mutex ctime
mutex limits
mutex ratio
@ -859,6 +861,7 @@ set version
shared_mutex cerrno
shared_mutex climits
shared_mutex cstdint
shared_mutex cstring
shared_mutex ctime
shared_mutex limits
shared_mutex ratio

1 algorithm cctype
653 memory_resource climits
654 memory_resource compare
655 memory_resource cstdint
656 memory_resource cstring
657 memory_resource ctime
658 memory_resource limits
659 memory_resource ratio
663 mutex climits
664 mutex compare
665 mutex cstdint
666 mutex cstring
667 mutex ctime
668 mutex limits
669 mutex ratio
861 shared_mutex cerrno
862 shared_mutex climits
863 shared_mutex cstdint
864 shared_mutex cstring
865 shared_mutex ctime
866 shared_mutex limits
867 shared_mutex ratio

View File

@ -0,0 +1,95 @@
//===----------------------------------------------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//
// REQUIRES: std-at-least-c++26
// <chrono>
// Test that <chrono> provides all of the hash specializations.
#include <chrono>
#include <type_traits>
#include "poisoned_hash_helper.h"
#include "test_macros.h"
static_assert(std::is_nothrow_invocable_v<std::hash<std::chrono::day>, std::chrono::day>);
static_assert(std::is_nothrow_invocable_v<std::hash<std::chrono::month>, std::chrono::month>);
static_assert(std::is_nothrow_invocable_v<std::hash<std::chrono::year>, std::chrono::year>);
static_assert(std::is_nothrow_invocable_v<std::hash<std::chrono::weekday>, std::chrono::weekday>);
static_assert(std::is_nothrow_invocable_v<std::hash<std::chrono::weekday_indexed>, std::chrono::weekday_indexed>);
static_assert(std::is_nothrow_invocable_v<std::hash<std::chrono::weekday_last>, std::chrono::weekday_last>);
static_assert(std::is_nothrow_invocable_v<std::hash<std::chrono::month_day>, std::chrono::month_day>);
static_assert(std::is_nothrow_invocable_v<std::hash<std::chrono::month_day_last>, std::chrono::month_day_last>);
static_assert(std::is_nothrow_invocable_v<std::hash<std::chrono::month_weekday>, std::chrono::month_weekday>);
static_assert(std::is_nothrow_invocable_v<std::hash<std::chrono::month_weekday_last>, std::chrono::month_weekday_last>);
static_assert(std::is_nothrow_invocable_v<std::hash<std::chrono::year_month>, std::chrono::year_month>);
static_assert(std::is_nothrow_invocable_v<std::hash<std::chrono::year_month_day>, std::chrono::year_month_day>);
static_assert(
std::is_nothrow_invocable_v<std::hash<std::chrono::year_month_day_last>, std::chrono::year_month_day_last>);
static_assert(std::is_nothrow_invocable_v<std::hash<std::chrono::year_month_weekday>, std::chrono::year_month_weekday>);
static_assert(
std::is_nothrow_invocable_v<std::hash<std::chrono::year_month_weekday_last>, std::chrono::year_month_weekday_last>);
#ifndef TEST_HAS_NO_EXPERIMENTAL_TZDB
static_assert(std::is_nothrow_invocable_v<std::hash<std::chrono::leap_second>, std::chrono::leap_second>);
#endif // TEST_HAS_NO_EXPERIMENTAL_TZDB
int main(int, char**) {
test_hash_enabled<std::chrono::nanoseconds>();
test_hash_enabled<std::chrono::microseconds>();
test_hash_enabled<std::chrono::milliseconds>();
test_hash_enabled<std::chrono::seconds>();
test_hash_enabled<std::chrono::minutes>();
test_hash_enabled<std::chrono::hours>();
test_hash_enabled<std::chrono::days>();
test_hash_enabled<std::chrono::weeks>();
test_hash_enabled<std::chrono::months>();
test_hash_enabled<std::chrono::years>();
test_hash_enabled<std::chrono::day>();
test_hash_enabled<std::chrono::month>();
test_hash_enabled<std::chrono::year>();
test_hash_enabled<std::chrono::weekday>();
test_hash_enabled<std::chrono::weekday_indexed>();
test_hash_enabled(std::chrono::weekday_last(std::chrono::weekday{}));
test_hash_enabled<std::chrono::month_day>();
test_hash_enabled(std::chrono::month_day_last(std::chrono::month{}));
test_hash_enabled(std::chrono::month_weekday(std::chrono::month{}, std::chrono::weekday_indexed{}));
test_hash_enabled(
std::chrono::month_weekday_last(std::chrono::month{}, std::chrono::weekday_last(std::chrono::weekday{})));
test_hash_enabled<std::chrono::year_month>();
test_hash_enabled<std::chrono::year_month_day>();
test_hash_enabled(
std::chrono::year_month_day_last(std::chrono::year{}, std::chrono::month_day_last(std::chrono::month{})));
test_hash_enabled<std::chrono::year_month_weekday>();
test_hash_enabled(std::chrono::year_month_weekday_last(
std::chrono::year{}, std::chrono::month{}, std::chrono::weekday_last(std::chrono::weekday{})));
#ifndef TEST_HAS_NO_EXPERIMENTAL_TZDB
test_hash_enabled(std::chrono::leap_second({}, std::chrono::sys_seconds{}, std::chrono::seconds{}));
# if !defined(TEST_HAS_NO_LOCALIZATION) && !defined(TEST_HAS_NO_TIME_ZONE_DATABASE) && !defined(TEST_HAS_NO_FILESYSTEM)
test_hash_enabled<std::chrono::zoned_time<std::chrono::milliseconds>>();
# endif // !defined(TEST_HAS_NO_LOCALIZATION) && !defined(TEST_HAS_NO_TIME_ZONE_DATABASE) &&
// !defined(TEST_HAS_NO_FILESYSTEM)
#endif // TEST_HAS_NO_EXPERIMENTAL_TZDB
return 0;
}