Closed tomaszkam closed 5 years ago
Discussion:
The current specification of the addition of year_month
and months
does not define unique result value.
To illustrate, both 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 [time.cal.ym.nonmembers] (http://eel.is/c++draft/time.cal.ym.nonmembers#3).
Proposed wording:
Apply the following changes to the specification of operator+ in [time.cal.ym.nonmembers]:
constexpr year_month operator+(const year_month& ym, const months& dm) noexcept;
Returns: A year_month value z such that z.ok() && z - ym == dm
.
Complexity: O(1) with respect to the value of dm
.
This is already implemented. Add new unit test to cover !year_month::ok() values. https://github.com/HowardHinnant/date/pull/425
Original comment:
E-mail thread: [isocpp-lib] year_month arithmetic