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.

3221. Result of year_month arithmetic with months is ambiguous

Section: [] 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.


The current specification of the addition of year_month and months does not define a 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 [].

[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.

  1. Modify [] as indicated:

    constexpr year_month operator+(const year_month& ym, const months& dm) noexcept;

    -3- Returns: A year_month value z such that z.ok() && z - ym == dm is true.

    Complexity: 𝒪(1) with respect to the value of dm.