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.

3273. Specify weekday_indexed to range of [0, 7]

Section: 30.8.7.2 [time.cal.wdidx.members] Status: C++20 Submitter: Howard Hinnant Opened: 2019-09-02 Last modified: 2021-02-25

Priority: 0

View all issues with C++20 status.

Discussion:

On one hand, we say that if you try to construct a weekday_indexed with index 0, you get an unspecified index instead (30.8.7.2 [time.cal.wdidx.members]/p1),:

The values held are unspecified if !wd.ok() or index is not in the range [1, 5].

OTOH, we take pains to pin down year_month_weekday's conversion to sys_days when the index is zero (30.8.7.2 [time.cal.wdidx.members]/p19):

If index() is 0 the returned sys_days represents the date 7 days prior to the first weekday() of year()/month().

This is inconsistent. We should allow a slightly wider range (say, [0, 7], since you need at least 3 bits anyway to represent the 5 distinct valid values, and the 0 value referred to by 30.8.7.2 [time.cal.wdidx.members]/p19.

[2019-09-24 Issue Prioritization]

Status to Tentatively Ready and priority to 0 after six positive votes on the reflector.

Proposed resolution:

This wording is relative to N4830.

  1. Modify 30.8.7.2 [time.cal.wdidx.members] as indicated:

    [Drafting note: As a drive-by fix a cleanup of "Constructs an object of type weekday_indexed" wording has been applied as well. ]

    constexpr weekday_indexed(const chrono::weekday& wd, unsigned index) noexcept;
    

    -1- Effects: Constructs an object of type weekday_indexed by initializingInitializes wd_ with wd and index_ with index. The values held are unspecified if !wd.ok() or index is not in the range [10, 57].