Title
Must *a return an lvalue when a is an input iterator?
Status
nad
Section
[iterator.concepts]
Submitter
Dave Abrahams

Created on 2001-02-05.00:00:00 last changed 163 months ago

Messages

Date: 2010-10-21.18:28:33

Rationale:

The current standard is clear and consistent. Input iterators that return rvalues are in fact implementable. They may in some cases require extra work, but it is still possible to define an operator-> in such cases: it doesn't have to return a T*, but may return a proxy type. No change to the standard is justified.

Date: 2001-02-05.00:00:00

We all "know" that input iterators are allowed to produce values when dereferenced of which there is no other in-memory copy.

But: Table 72, with a careful reading, seems to imply that this can only be the case if the value_type has no members (e.g. is a built-in type).

The problem occurs in the following entry:

  a->m     pre: (*a).m is well-defined
           Equivalent to (*a).m

*a.m can be well-defined if *a is not a reference type, but since operator->() must return a pointer for a->m to be well-formed, it needs something to return a pointer to. This seems to indicate that *a must be buffered somewhere to make a legal input iterator.

I don't think this was intentional.

History
Date User Action Args
2010-10-21 18:28:33adminsetmessages: + msg2177
2001-02-05 00:00:00admincreate