346. Some iterator member functions should be const

Section: 99 [iterator.concepts] Status: CD1 Submitter: Jeremy Siek Opened: 2001-10-20 Last modified: 2016-02-10

Priority: Not Prioritized

View all other issues in [iterator.concepts].

View all issues with CD1 status.


Iterator member functions and operators that do not change the state of the iterator should be defined as const member functions or as functions that take iterators either by const reference or by value. The standard does not explicitly state which functions should be const. Since this a fairly common mistake, the following changes are suggested to make this explicit.

The tables almost indicate constness properly through naming: r for non-const and a,b for const iterators. The following changes make this more explicit and also fix a couple problems.

Proposed resolution:

In 99 [iterator.concepts] Change the first section of p9 from "In the following sections, a and b denote values of X..." to "In the following sections, a and b denote values of type const X...".

In Table 73, change

    a->m   U&         ...


    a->m   const U&   ...
    r->m   U&         ...

In Table 73 expression column, change

    *a = t


    *r = t

[Redmond: The container requirements should be reviewed to see if the same problem appears there.]