1. Abstract
We propose to relax the requirements on the
template parameter of
.
2. Revision History
2.1. Revision 1
Alter proposed wording per Jonathan Wakely’s suggestion.2.2. Revision 0
Initial revision.3. Motivation
It is sometimes useful to give
a
template
argument that does not meet the Cpp17Clock requirements. The most obvious use
case is the
introduced in C++20. This "clock" is not really a clock
at all. It has no functionality for getting the current time. Nevertheless, C++20
utilizes
to represent a family of
time points that do not represent instants in time until they are paired with a specific
. This gives "local time" a distinct type from "system/UTC time"
in order to reduce the possibility of the programmer confusing these two types in their code.
Since the introduction of
, more use cases for "not-quite-clocks" have become apparent:
-
Some people need a stateful clock. This requires a non-static
function.now () -
Some people would like to represent "time of day" as a distinct
.time_point -
It is sometimes useful to represent time points as defined by some external system not controlled by you, where you can’t generate the current time_point easily or at all.
One example might be value of timestamp counter on different computer. You can’t easily generate the current value, but you can still meaningfully manipulate existing values generated by other means: compare them, calculate differences between them, etc.
4. Wording
Remove paragraph 1 in [time.point]:
local_t
.5. Effect on existing code
This change should not affect any conforming code because the requirement is only relaxed.
6. Effect on implementations
This change should not have an effect on most of implementations because in practice they do not use any of the members of
outside of [thread]. [thread.req.paramname] places additional requirements on the
template parameter, namely that
is true
.
This change is effectively already proven to be safe because of the existence of
, where
is an empty class.