478. Should forward iterator requirements table have a line for r->m?

Section: [forward.iterators] Status: CD1 Submitter: Dave Abrahams Opened: 2004-07-11 Last modified: 2016-01-28 10:19:27 UTC

Priority: Not Prioritized

View all other issues in [forward.iterators].

View all issues with CD1 status.

Duplicate of: 477


The Forward Iterator requirements table contains the following:

 expression  return type         operational  precondition
  ==========  ==================  ===========  ==========================
  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

Proposed resolution:

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

"const X"


"X or const X"

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


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