This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of Tentatively Ready status.

3927. Unclear preconditions for operator[] for sequence containers

Section: 24.2.4 [sequence.reqmts] Status: Tentatively Ready Submitter: Ville Voutilainen Opened: 2023-04-24 Last modified: 2023-05-24

Priority: Not Prioritized

View other active issues in [sequence.reqmts].

View all other issues in [sequence.reqmts].

View all issues with Tentatively Ready status.

Discussion:

In 24.2.4 [sequence.reqmts]/118, we specify what a[n] means for a sequence container a, but we don't state that it actually has preconditions, other than implied ones.

When we want to use implied preconditions, we can actually get them by using the "Effects: Equivalent to..." wording.

[2023-05-24; Reflector poll]

Set status to Tentatively Ready after six votes in favour during reflector poll.

Proposed resolution:

This wording is relative to N4944.

  1. Modify 24.2.4 [sequence.reqmts] as indicated:

    a[n]
    

    -118- Result: reference; const_reference for constant a

    -119- ReturnsEffects: Equivalent to: return *(a.begin() + n);

    -120- Remarks: Required for basic_string, array, deque, and vector.