Title
Operator-> for const forward iterators
Status
dup
Section
[forward.iterators]
Submitter
Dave Abrahams

Created on 2004-07-11.00:00:00 last changed 171 months ago

Messages

Date: 2010-10-21.18:28:33

Rationale:

The LWG agrees that this is a real problem. Marked as a DUP because the LWG chose to adopt the solution proposed in 478.

Duplicate: 478

Date: 2004-07-11.00:00:00

The Forward Iterator requirements table contains the following:

 expression  return type         operational  precondition
                                  semantics
  ==========  ==================  ===========  ==========================
  a->m        U& if X is mutable, (*a).m       pre: (*a).m is well-defined.
              otherwise const U&

  r->m        U&                  (*r).m       pre: (*r).m is well-defined.

The first line is exactly right. The second line is wrong. Basically it implies that the const-ness of the iterator affects the const-ness of referenced members. But Paragraph 11 of [lib.iterator.requirements] says:

In the following sections, a and b denote values of type const X, n denotes a value of the difference type Distance, u, tmp, and m denote identifiers, r denotes a value of X&, t denotes a value of value type T, o denotes a value of some type that is writable to the output iterator.

AFAICT if we need the second line at all, it should read the same as the first line.

Related issue: 478

History
Date User Action Args
2010-10-21 18:28:33adminsetmessages: + msg2783
2004-07-11 00:00:00admincreate