year_month
arithmetic with months
is ambiguousSection: 30.8.13.3 [time.cal.ym.nonmembers] Status: C++20 Submitter: Tomasz Kamiński Opened: 2019-06-16 Last modified: 2021-02-25
Priority: 0
View all issues with C++20 status.
Discussion:
The current specification of the addition of year_month
and
months
does not define a unique result value.
year(2019)/month(1)
and year(2018)/month(13)
are valid results of year(2018)/month(12) + months(1)
addition,
according to the spec in 30.8.13.3 [time.cal.ym.nonmembers].
[2019-06-24; LWG discussion]
During discussions on the LWG reflector there was a preference to add "is true
" at the
end of the modified Returns: element. This additional edit has been applied to Tomasz'
original wording below.
[2019-07 Issue Prioritization]
Status to Tentatively Ready after five positive votes on the reflector.
Proposed resolution:
This wording is relative to N4810.
Modify 30.8.13.3 [time.cal.ym.nonmembers] as indicated:
constexpr year_month operator+(const year_month& ym, const months& dm) noexcept;-3- Returns: A
Complexity:year_month
valuez
such thatz.ok() && z - ym == dm
istrue
.𝒪(1)
with respect to the value ofdm
.