This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of CD1 status.
Section: 24.3.5.5 [forward.iterators] Status: CD1 Submitter: Dave Abrahams Opened: 2004-07-11 Last modified: 2016-01-28
Priority: Not Prioritized
View all other issues in [forward.iterators].
View all issues with CD1 status.
Duplicate of: 477
Discussion:
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.
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].
Rationale:
This is a defect because it constrains an lvalue to returning a modifiable lvalue.