This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of C++20 status.
year_month_day
conversion to sys_days
uses not-existing member functionSection: 30.8.14.2 [time.cal.ymd.members] Status: C++20 Submitter: Tomasz Kamiński Opened: 2019-05-19 Last modified: 2021-02-25
Priority: 0
View all issues with C++20 status.
Discussion:
The current specification of the year_month_day
conversion function to sys_days
,
uses the day
member function on the sys_days
(a.k.a.
time_point<system_clock, days>
), that does not exist.
sys_days{y_/m_/last}.day()
is
ill-formed:
[…] Otherwise, if
y_.ok() && m_.ok()
istrue
, returns asys_days
which is offset fromsys_days{y_/m_/last}
by the number of daysd_
is offset fromsys_days{y_/m_/last}.day()
. Otherwise the value returned is unspecified.
[2019-06-08; Priority to 0 and Status to Tentatively Ready after six positive votes on the reflector.]
Proposed resolution:
This wording is relative to N4810.
Modify 30.8.14.2 [time.cal.ymd.members] as indicated:
constexpr operator sys_days() const noexcept;-18- Returns: If
ok()
, returns asys_days
holding a count of days from thesys_days
epoch to*this
(a negative value if*this
represents a date prior to thesys_days
epoch). Otherwise, ify_.ok() && m_.ok()
istrue
, returnssys_days{y_/m_/1d} + (d_ - 1d)
a. Otherwise the value returned is unspecified.sys_days
which is offset fromsys_days{y_/m_/last}
by the number of daysd_
is offset fromsys_days{y_/m_/last}.day()