Movatterモバイル変換


[0]ホーム

URL:



This page is a snapshot from the LWG issues list, see theLibrary Active Issues List for more information and the meaning ofResolved status.

2054.time_point constructors need to beconstexpr

Section: 30.6[time.point]Status:ResolvedSubmitter: Anthony WilliamsOpened: 2011-05-13Last modified: 2016-01-28

Priority:Not Prioritized

View all issues withResolved status.

Discussion:

In 30.6[time.point],time_point::min() andtime_point::max() are listed asconstexpr. However,time_point has noconstexpr constructors, so is not a literal type, and so these functions cannot beconstexpr without adding aconstexpr constructor for implementation purposes.

Proposed resolution: Addconstexpr to the constructors oftime_point. The effects ofthe constructor template basically imply that the member functiontime_since_epoch() isintended to beconstexpr as well.

[2012, Portland]

Resolved by adopting papern3469.

Proposed resolution:

This wording is relative to the FDIS.

  1. 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 epochconstexpr 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;  […]};
  2. Alter the declarations in 30.6.2[time.point.cons]:

    constexpr time_point();

    -1-Effects: Constructs an object of typetime_point, initializingd_ withduration::zero(). Such atime_point object represents the epoch.

    constexpr explicit time_point(const duration& d);

    -2-Effects: Constructs an object of typetime_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 unlessDuration2 is implicitlyconvertible toduration.

    -4-Effects: Constructs an object of typetime_point, initializingd_ witht.time_since_epoch().

  3. Alter the declaration in 30.6.3[time.point.observer]:

    constexpr duration time_since_epoch() const;

    -1-Returns: d_.


[8]ページ先頭

©2009-2026 Movatter.jp