Movatterモバイル変換


[0]ホーム

URL:



This page is a snapshot from the LWG issues list, see theLibrary Active Issues List for more information and the meaning ofC++17 status.

2698. Effect ofassign() on iterators/pointers/references

Section: 23.2.4[sequence.reqmts]Status:C++17Submitter: Tim SongOpened: 2016-04-25Last modified: 2017-07-30

Priority:0

View otheractive issues in [sequence.reqmts].

View all otherissues in [sequence.reqmts].

View all issues withC++17 status.

Discussion:

The sequence container requirements table says nothing about the effect ofassign() on iterators, pointers or references into the container. Before LWG2209(i) (and LWG320(i) forstd::list),assign() was specified as "erase everything theninsert", which implies wholesale invalidation from the "erase everything" part. With that gone, the blanket "no invalidation" wording in 23.2.2[container.requirements.general]/12 would seem to apply, which makes absolutely no sense.

The proposed wording below simply spells out the invalidation rule implied by the previous "erase everything" wording.

[2016-05 Issues Telecon]

This is related to2256(i)

Proposed resolution:

This wording is relative to N4582.

  1. In 23.2.4[sequence.reqmts], edit Table 107 (Sequence container requirements) as indicated:

    Table 107 — Sequence container requirements (in addition to container)
    ExpressionReturn typeAssertion/note
    pre-/post-condition
    […]
    a.assign(i, j)voidRequires:T shall beEmplaceConstructible intoX from*i and assignable from*i.
    Forvector, if the iterator does not meet the forward iterator requirements (24.2.5),
    T shall also beMoveInsertable intoX.
    Each iterator in the range[i, j) shall be dereferenced exactly once.
    pre:i,j are not iterators intoa.
    Replaces elements ina with a copy of[i, j).
    Invalidates all references, pointers and iterators referring to the elements ofa.
    Forvector anddeque, also invalidates the past-the-end iterator.
    […]
    a.assign(n, t)voidRequires:T shall beCopyInsertable intoX andCopyAssignable.
    pre:t is not a reference intoa.
    Replaces elements ina withn copies oft.
    Invalidates all references, pointers and iterators referring to the elements ofa.
    Forvector anddeque, also invalidates the past-the-end iterator.

[8]ページ先頭

©2009-2026 Movatter.jp