Skip to content

Commit 9fcb2ae

Browse files
jwakelytkoeppe
authored andcommitted
P2592R3 Hashing support for std::chrono value classes
Editorial: Added \ref from synopsis to [time.hash]
1 parent 7ecd53a commit 9fcb2ae

File tree

2 files changed

+121
-1
lines changed

2 files changed

+121
-1
lines changed

source/support.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,7 @@
585585
#define @\defnlibxname{cpp_lib_byteswap}@ 202110L // also in \libheader{bit}
586586
#define @\defnlibxname{cpp_lib_char8_t}@ 201907L
587587
// also in \libheader{atomic}, \libheader{filesystem}, \libheader{istream}, \libheader{limits}, \libheader{locale}, \libheader{ostream}, \libheader{string}, \libheader{string_view}
588-
#define @\defnlibxname{cpp_lib_chrono}@ 201907L // also in \libheader{chrono}
588+
#define @\defnlibxname{cpp_lib_chrono}@ 202306L // also in \libheader{chrono}
589589
#define @\defnlibxname{cpp_lib_chrono_udls}@ 201304L // also in \libheader{chrono}
590590
#define @\defnlibxname{cpp_lib_clamp}@ 201603L // also in \libheader{algorithm}
591591
#define @\defnlibxname{cpp_lib_common_reference}@ 202302L // also in \libheader{type_traits}

source/time.tex

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -942,6 +942,31 @@
942942
namespace std::chrono {
943943
using namespace literals::chrono_literals;
944944
}
945+
946+
namespace std {
947+
// \ref{time.hash}, hash support
948+
template<class T> struct hash;
949+
template<class Rep, class Period> struct hash<chrono::duration<Rep, Period>>;
950+
template<class Clock, class Duration> struct hash<chrono::time_point<Clock, Duration>>;
951+
template<> struct hash<chrono::day>;
952+
template<> struct hash<chrono::month>;
953+
template<> struct hash<chrono::year>;
954+
template<> struct hash<chrono::weekday>;
955+
template<> struct hash<chrono::weekday_indexed>;
956+
template<> struct hash<chrono::weekday_last>;
957+
template<> struct hash<chrono::month_day>;
958+
template<> struct hash<chrono::month_day_last>;
959+
template<> struct hash<chrono::month_weekday>;
960+
template<> struct hash<chrono::month_weekday_last>;
961+
template<> struct hash<chrono::year_month>;
962+
template<> struct hash<chrono::year_month_day>;
963+
template<> struct hash<chrono::year_month_day_last>;
964+
template<> struct hash<chrono::year_month_weekday>;
965+
template<> struct hash<chrono::year_month_weekday_last>;
966+
template<class Duration, class TimeZonePtr>
967+
struct hash<chrono::zoned_time<Duration, TimeZonePtr>>;
968+
template<> struct hash<chrono::leap_second>;
969+
}
945970
\end{codeblock}
946971

947972
\rSec1[time.clock.req]{\oldconcept{Clock} requirements}
@@ -11449,6 +11474,101 @@
1144911474

1145011475
\indexlibrary{\idxcode{parse}|)}
1145111476

11477+
\rSec1[time.hash]{Hash support}
11478+
11479+
\indexlibrarymember{hash}{duration}%
11480+
\begin{itemdecl}
11481+
template<class Rep, class Period> struct hash<chrono::duration<Rep, Period>>;
11482+
\end{itemdecl}
11483+
11484+
\begin{itemdescr}
11485+
\pnum
11486+
The specialization \tcode{hash<chrono::duration<Rep, Period>>} is enabled\iref{unord.hash}
11487+
if and only if \\% newline to fix overfull hbox
11488+
\tcode{hash<Rep>} is enabled.
11489+
The member functions are not guaranteed to be \keyword{noexcept}.
11490+
\end{itemdescr}
11491+
11492+
\indexlibrarymember{hash}{time_point}%
11493+
\begin{itemdecl}
11494+
template<class Clock, class Duration> struct hash<chrono::time_point<Clock, Duration>>;
11495+
\end{itemdecl}
11496+
11497+
\begin{itemdescr}
11498+
\pnum
11499+
The specialization \tcode{hash<chrono::time_point<Clock, Duration>>} is enabled\iref{unord.hash}
11500+
if and only if \tcode{hash<Duration>} is enabled.
11501+
The member functions are not guaranteed to be \keyword{noexcept}.
11502+
\end{itemdescr}
11503+
11504+
\indexlibrarymember{hash}{day}%
11505+
\indexlibrarymember{hash}{month}%
11506+
\indexlibrarymember{hash}{year}%
11507+
\indexlibrarymember{hash}{weekday}%
11508+
\indexlibrarymember{hash}{weekday_indexed}%
11509+
\indexlibrarymember{hash}{weekday_last}%
11510+
\indexlibrarymember{hash}{month_day}%
11511+
\indexlibrarymember{hash}{month_day_last}%
11512+
\indexlibrarymember{hash}{month_weekday}%
11513+
\indexlibrarymember{hash}{month_weekday_last}%
11514+
\indexlibrarymember{hash}{year_month}%
11515+
\indexlibrarymember{hash}{year_month_day}%
11516+
\indexlibrarymember{hash}{year_month_day_last}%
11517+
\indexlibrarymember{hash}{year_month_weekday}%
11518+
\indexlibrarymember{hash}{year_month_weekday_last}%
11519+
\begin{itemdecl}
11520+
template<> struct hash<chrono::day>;
11521+
template<> struct hash<chrono::month>;
11522+
template<> struct hash<chrono::year>;
11523+
template<> struct hash<chrono::weekday>;
11524+
template<> struct hash<chrono::weekday_indexed>;
11525+
template<> struct hash<chrono::weekday_last>;
11526+
template<> struct hash<chrono::month_day>;
11527+
template<> struct hash<chrono::month_day_last>;
11528+
template<> struct hash<chrono::month_weekday>;
11529+
template<> struct hash<chrono::month_weekday_last>;
11530+
template<> struct hash<chrono::year_month>;
11531+
template<> struct hash<chrono::year_month_day>;
11532+
template<> struct hash<chrono::year_month_day_last>;
11533+
template<> struct hash<chrono::year_month_weekday>;
11534+
template<> struct hash<chrono::year_month_weekday_last>;
11535+
\end{itemdecl}
11536+
11537+
\begin{itemdescr}
11538+
\pnum
11539+
The specializations are enabled\iref{unord.hash}.
11540+
\begin{note}
11541+
All the \tcode{hash<Key>} specializations listed above meet the
11542+
\oldconcept{Cpp17Hash} requirements, even when called on objects \tcode{k}
11543+
of type \tcode{Key} such that \tcode{k.ok()} is \tcode{false}.
11544+
\end{note}
11545+
\end{itemdescr}
11546+
11547+
\indexlibrarymember{hash}{zoned_time}%
11548+
\begin{itemdecl}
11549+
template<class Duration, class TimeZonePtr>
11550+
struct hash<chrono::zoned_time<Duration, TimeZonePtr>>;
11551+
\end{itemdecl}
11552+
11553+
\begin{itemdescr}
11554+
\pnum
11555+
The specialization \tcode{hash<chrono::zoned_time<Durationm TimeZonePtr>>}
11556+
is enabled\iref{unord.hash}
11557+
if and only if \tcode{hash<Duration>} is enabled and
11558+
\tcode{hash<TimeZonePtr>} is enabled.
11559+
The member functions are not guaranteed to be \keyword{noexcept}.
11560+
\end{itemdescr}
11561+
11562+
\indexlibrarymember{hash}{leap_second}%
11563+
\begin{itemdecl}
11564+
template<> struct hash<chrono::leap_second>;
11565+
\end{itemdecl}
11566+
11567+
\begin{itemdescr}
11568+
\pnum
11569+
The specialization is enabled\iref{unord.hash}.
11570+
\end{itemdescr}
11571+
1145211572
\rSec1[ctime.syn]{Header \tcode{<ctime>} synopsis}
1145311573

1145411574
\indexheader{ctime}%

0 commit comments

Comments
 (0)