Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

[sequence.reqmts], [associative.reqmts.general]: Grammatical corrections for a.erase(q)

Aperta Adatta ai principianti
#9,166 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
72/100
Tipo di issue
Documentazione
Chiarezza
Specificata chiaramente
Stato di attività
Tranquilla
Stack tecnologico
cpp
Ambito
documentation

Direzione di ricerca

Inizia con le clausole [sequence.reqmts] e [associative.reqmts.general] nella bozza della sorgente. Applica le modifiche alla formulazione della resolution sia alle occorrenze di a.erase(q) sia alla formulazione analoga di a.erase(r), quindi verifica che ogni descrizione del valore restituito riporti “If no element follows” e corrisponda al testo proposto nell’issue.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

P3-Other

Discussion:

The existing wording for a.erase(q) caught me out because it was ambiguous without referring back through the standard to prior knowledge. It also caught out others I mentioned it to. The ambiguity is due to grammatical incorrectness.

Current wording is:

Returns: An iterator that points to the element immediately following q prior to the element being
erased. If no such element exists, a.end() is returned.

The key ambiguity is in the phrase "If no such element exists", which depending on your reading, may either refer to "the element immediately following q", or
to "the element being erased". Grammatically, because the latter is closer to the secondary sentence, the logical conclusion when taking the paragraph in isolation that that is the 'element' referred to. This is apparently not the case.
The semantics of the two interpretations are as follows:

"the element immediately following q" - if no element exists after the element being erased, return end().

"the element being erased" - if erase has been supplied an iterator which does not point to an element in *this, return end().

The correct interpretation relies on knowledge of the blanket wording in [sequence.reqmts] 2.11, which states that q must be a valid constant interator into a. However, most people reading the standard for the first, second or even third time may not make that backwards leap to establish that the grammatical structure of the sentence is predicated on a sentence in an earlier passage.

Making this grammatically-correct is easily achievable by changing the phrase to "If no element follows q".

The similar wording for sequence.reqmts a.erase(q1, q2) is unambiguous because there is 'elements' and 'element', making it clear what 'element' in the second sentence refers to.

However, the same wording occurs later in the standard under [associative.reqmts.general].

Resolution:

This wording is relative to N5036.

  1. Modify [sequence.reqmts] as indicated:
  a.erase(q)

       -45- Result: iterator.
       -46- Preconditions: For vector, inplace_vector, and deque, T is Cpp17MoveAssignable.
       -47- Effects: Erases the element pointed to by q.
       -48- Returns: An iterator that points to the element immediately following q prior to the element being
       erased. If no element follows q, a.end() is returned.

  1. Modify [associative.reqmts.general] as indicated:
    a.erase(q)

        -126- Result: iterator
        -127- Effects: Erases the element pointed to by q.
        -128- Returns: An iterator pointing to the element immediately following q prior to the element being erased. 
        If no element follows q, returns a.end().
a.erase(r)

    -130- Result: iterator
    -131- Effects: Erases the element pointed to by r.
    -132- Returns: An iterator pointing to the element immediately following r prior to the element being erased. 
    If no element follows r, returns a.end().
Lingua principale
TeX
Stelle
227
Fork
815
Merge medio
17h 21m
PR unite (30g)
30

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di cplusplus/draft

Tutte le issue di cplusplus/draft

Issue simili

Altre issue su Documentation

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.