Movatterモバイル変換


[0]ホーム

URL:



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

98. Input iterator requirements are badly written

Section: 24.3.5.3[input.iterators]Status:CD1Submitter: AFNOROpened: 1998-10-07Last modified: 2016-01-28

Priority:Not Prioritized

View otheractive issues in [input.iterators].

View all otherissues in [input.iterators].

View all issues withCD1 status.

Discussion:

Table 72 in 24.3.5.3[input.iterators] specifies semantics for*r++ of:

  { T tmp = *r; ++r; return tmp; }

There are two problems with this. First, the return type isspecified to be "T", as opposed to something like "convertible to T".This is too specific: we want to allow *r++ to return an lvalue.

Second, writing the semantics in terms of code misleadinglysuggests that the effects *r++ should precisely replicate the behaviorof this code, including side effects. (Does this mean that *r++should invoke the copy constructor exactly as many times as the samplecode above would?) See issue334(i) for a similarproblem.

Proposed resolution:

In Table 72 in 24.3.5.3[input.iterators], change the return typefor*r++ fromT to "convertible to T".

Rationale:

This issue has two parts: the return type, and the number of times the copy constructor is invoked.

The LWG believes the the first part is a real issue. It's inappropriate for the return type to be specified so much more precisely for *r++ than it is for *r. In particular, if r is of (say) typeint*, then *r++ isn'tint, butint&.

The LWG does not believe that the number of times the copy constructor is invoked is a real issue. This can vary in any case, because of language rules on copy constructor elision. That's too much to read into these semantics clauses.

Additionally, as Dave Abrahams pointed out (c++std-lib-13703): since we're told (24.1/3) that forward iterators satisfy all the requirements of input iterators, we can't impose any requirements in the Input Iterator requirements table that forward iterators don't satisfy.


[8]ページ先頭

©2009-2026 Movatter.jp