Skip to content

[time.cal] improve std::chrono::month operator+'s description of arithmetic mod 12 #1974

@zygoloid

Description

@zygoloid

Perhaps we could just say:

Returns: a month with m_ equal to the sum of unsigned{x} and y.count(), reduced modulo 12 to an integer in [1, 12].

or something like that, rather than defining an auxiliary modulo(n, 12) function and going on an excursion to a definition of Euclidean division.

One problem: this is not entirely editorial, as the new wording does not admit any undefined behavior, whereas the description in the existing wording results in UB when long long and months' representation type are the same size and the months value is nearly LLONG_MAX. The undefined behavior here does not appear to be especially useful; implementations can easily produce the correct result by reducing the months value modulo 12 first, if they chose a representation type for months that is the same size as long long.

Metadata

Metadata

Assignees

No one assigned

    Labels

    lwgIssue must be reviewed by LWG.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions