time_point
constructors need to be constexpr
Section: 30.6 [time.point] Status: Resolved Submitter: Anthony Williams Opened: 2011-05-13 Last modified: 2016-01-28
Priority: Not Prioritized
View all issues with Resolved status.
Discussion:
In 30.6 [time.point], time_point::min()
and time_point::max()
are listed as constexpr
. However, time_point
has no constexpr
constructors,
so is not a literal type, and so these functions cannot be constexpr
without adding a
constexpr
constructor for implementation purposes.
constexpr
to the constructors of time_point
. The effects of
the constructor template basically imply that the member function time_since_epoch()
is
intended to be constexpr
as well.
[2012, Portland]
Resolved by adopting paper n3469.
Proposed resolution:
This wording is relative to the FDIS.
Alter the class template definition in 30.6 [time.point] as follows:
template <class Clock, class Duration = typename Clock::duration> class time_point { […] public: // 20.11.6.1, construct: constexpr time_point(); // has value epoch constexpr explicit time_point(const duration& d); // same as time_point() + d template <class Duration2> constexpr time_point(const time_point<clock, Duration2>& t); // 20.11.6.2, observer: constexpr duration time_since_epoch() const; […] };
Alter the declarations in 30.6.2 [time.point.cons]:
constexpr time_point();-1- Effects: Constructs an object of type
time_point
, initializingd_
withduration::zero()
. Such atime_point
object represents the epoch.
constexpr explicit time_point(const duration& d);-2- Effects: Constructs an object of type
time_point
, initializingd_
withd
. Such atime_point
object represents the epoch+ d
.
template <class Duration2> constexpr time_point(const time_point<clock, Duration2>& t);-3- Remarks: This constructor shall not participate in overload resolution unless
-4- Effects: Constructs an object of typeDuration2
is implicitly convertible toduration
.time_point
, initializingd_
witht.time_since_epoch()
.
Alter the declaration in 30.6.3 [time.point.observer]:
constexpr duration time_since_epoch() const;-1- Returns: d_.