Title
Some iterator member functions should be const
Status
cd1
Section
[iterator.concepts]
Submitter
Jeremy Siek

Created on 2001-10-20.00:00:00 last changed 171 months ago

Messages

Date: 2010-10-21.18:28:33

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

Date: 2010-10-21.18:28:33

Proposed resolution:

In [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
Date: 2001-10-20.00:00:00

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.

History
Date User Action Args
2010-10-21 18:28:33adminsetmessages: + msg2305
2010-10-21 18:28:33adminsetmessages: + msg2304
2001-10-20 00:00:00admincreate