Skip to content

P2592R3 Hashing support for std::chrono value classes #6332

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion source/support.tex
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@
#define @\defnlibxname{cpp_lib_byteswap}@ 202110L // also in \libheader{bit}
#define @\defnlibxname{cpp_lib_char8_t}@ 201907L
// also in \libheader{atomic}, \libheader{filesystem}, \libheader{istream}, \libheader{limits}, \libheader{locale}, \libheader{ostream}, \libheader{string}, \libheader{string_view}
#define @\defnlibxname{cpp_lib_chrono}@ 201907L // also in \libheader{chrono}
#define @\defnlibxname{cpp_lib_chrono}@ 202306L // also in \libheader{chrono}
#define @\defnlibxname{cpp_lib_chrono_udls}@ 201304L // also in \libheader{chrono}
#define @\defnlibxname{cpp_lib_clamp}@ 201603L // also in \libheader{algorithm}
#define @\defnlibxname{cpp_lib_common_reference}@ 202302L // also in \libheader{type_traits}
Expand Down
120 changes: 120 additions & 0 deletions source/time.tex
Original file line number Diff line number Diff line change
Expand Up @@ -942,6 +942,31 @@
namespace std::chrono {
using namespace literals::chrono_literals;
}

namespace std {
// \ref{time.hash}, hash support
template<class T> struct hash;
template<class Rep, class Period> struct hash<chrono::duration<Rep, Period>>;
template<class Clock, class Duration> struct hash<chrono::time_point<Clock, Duration>>;
template<> struct hash<chrono::day>;
template<> struct hash<chrono::month>;
template<> struct hash<chrono::year>;
template<> struct hash<chrono::weekday>;
template<> struct hash<chrono::weekday_indexed>;
template<> struct hash<chrono::weekday_last>;
template<> struct hash<chrono::month_day>;
template<> struct hash<chrono::month_day_last>;
template<> struct hash<chrono::month_weekday>;
template<> struct hash<chrono::month_weekday_last>;
template<> struct hash<chrono::year_month>;
template<> struct hash<chrono::year_month_day>;
template<> struct hash<chrono::year_month_day_last>;
template<> struct hash<chrono::year_month_weekday>;
template<> struct hash<chrono::year_month_weekday_last>;
template<class Duration, class TimeZonePtr>
struct hash<chrono::zoned_time<Duration, TimeZonePtr>>;
template<> struct hash<chrono::leap_second>;
}
\end{codeblock}

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

\indexlibrary{\idxcode{parse}|)}

\rSec1[time.hash]{Hash support}

\indexlibrarymember{hash}{duration}%
\begin{itemdecl}
template<class Rep, class Period> struct hash<chrono::duration<Rep, Period>>;
\end{itemdecl}

\begin{itemdescr}
\pnum
The specialization \tcode{hash<chrono::duration<Rep, Period>>} is enabled\iref{unord.hash}
if and only if \\% newline to fix overfull hbox
\tcode{hash<Rep>} is enabled.
The member functions are not guaranteed to be \keyword{noexcept}.
\end{itemdescr}

\indexlibrarymember{hash}{time_point}%
\begin{itemdecl}
template<class Clock, class Duration> struct hash<chrono::time_point<Clock, Duration>>;
\end{itemdecl}

\begin{itemdescr}
\pnum
The specialization \tcode{hash<chrono::time_point<Clock, Duration>>} is enabled\iref{unord.hash}
if and only if \tcode{hash<Duration>} is enabled.
The member functions are not guaranteed to be \keyword{noexcept}.
\end{itemdescr}

\indexlibrarymember{hash}{day}%
\indexlibrarymember{hash}{month}%
\indexlibrarymember{hash}{year}%
\indexlibrarymember{hash}{weekday}%
\indexlibrarymember{hash}{weekday_indexed}%
\indexlibrarymember{hash}{weekday_last}%
\indexlibrarymember{hash}{month_day}%
\indexlibrarymember{hash}{month_day_last}%
\indexlibrarymember{hash}{month_weekday}%
\indexlibrarymember{hash}{month_weekday_last}%
\indexlibrarymember{hash}{year_month}%
\indexlibrarymember{hash}{year_month_day}%
\indexlibrarymember{hash}{year_month_day_last}%
\indexlibrarymember{hash}{year_month_weekday}%
\indexlibrarymember{hash}{year_month_weekday_last}%
\begin{itemdecl}
template<> struct hash<chrono::day>;
template<> struct hash<chrono::month>;
template<> struct hash<chrono::year>;
template<> struct hash<chrono::weekday>;
template<> struct hash<chrono::weekday_indexed>;
template<> struct hash<chrono::weekday_last>;
template<> struct hash<chrono::month_day>;
template<> struct hash<chrono::month_day_last>;
template<> struct hash<chrono::month_weekday>;
template<> struct hash<chrono::month_weekday_last>;
template<> struct hash<chrono::year_month>;
template<> struct hash<chrono::year_month_day>;
template<> struct hash<chrono::year_month_day_last>;
template<> struct hash<chrono::year_month_weekday>;
template<> struct hash<chrono::year_month_weekday_last>;
\end{itemdecl}

\begin{itemdescr}
\pnum
The specializations are enabled\iref{unord.hash}.
\begin{note}
All the \tcode{hash<Key>} specializations listed above meet the
\oldconcept{Cpp17Hash} requirements, even when called on objects \tcode{k}
of type \tcode{Key} such that \tcode{k.ok()} is \tcode{false}.
\end{note}
\end{itemdescr}

\indexlibrarymember{hash}{zoned_time}%
\begin{itemdecl}
template<class Duration, class TimeZonePtr>
struct hash<chrono::zoned_time<Duration, TimeZonePtr>>;
\end{itemdecl}

\begin{itemdescr}
\pnum
The specialization \tcode{hash<chrono::zoned_time<Durationm TimeZonePtr>>}
is enabled\iref{unord.hash}
if and only if \tcode{hash<Duration>} is enabled and
\tcode{hash<TimeZonePtr>} is enabled.
The member functions are not guaranteed to be \keyword{noexcept}.
\end{itemdescr}

\indexlibrarymember{hash}{leap_second}%
\begin{itemdecl}
template<> struct hash<chrono::leap_second>;
\end{itemdecl}

\begin{itemdescr}
\pnum
The specialization is enabled\iref{unord.hash}.
\end{itemdescr}

\rSec1[ctime.syn]{Header \tcode{<ctime>} synopsis}

\indexheader{ctime}%
Expand Down