Title
Should forward iterator requirements table have a line for r->m?
Status
cd1
Section
[forward.iterators]
Submitter
Dave Abrahams

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

Messages

Date: 2010-10-21.18:28:33

Rationale:

This is a defect because it constrains an lvalue to returning a modifiable lvalue.

Date: 2010-10-21.18:28:33

Proposed resolution:

Remove the "r->m" line from the Forward Iterator requirements table. Change

"const X"

to

"X or const X"

in paragraph 11 of [lib.iterator.requirements].

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 second line may be unnecessary. 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.

Because operators can be overloaded on an iterator's const-ness, the current requirements allow iterators to make many of the operations specified using the identifiers a and b invalid for non-const iterators.

Related issue: 477

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