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.

### 346. Some iterator member functions should be const

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

Priority: Not Prioritized

View all other issues in [iterator.concepts].

View all issues with CD1 status.

Discussion:

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 25.3.4 [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&         ...

to

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

In Table 73 expression column, change

        *a = t

to

        *r = t

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