3927. Unclear preconditions for operator[] for sequence containers

Section: 24.2.4 [sequence.reqmts] Status: WP Submitter: Ville Voutilainen Opened: 2023-04-24 Last modified: 2023-06-19 14:50:03 UTC

Priority: Not Prioritized

View other active issues in [sequence.reqmts].

View all other issues in [sequence.reqmts].

View all issues with WP status.


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.

[2023-06-17 Approved in Varna. Status changed: Voting → WP.]

Proposed resolution:

This wording is relative to N4944.

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


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