Topic: Defect Report: Constant Iterator


Author: jpotter@falcon.lhup.edu (John Potter)
Date: 14 Nov 00 04:28:25 GMT
Raw View
 [Moderator's note: this defect report has been
 forwarded to the C++ committee. -moderator(fjh).]

24.1[lib.iterator.requirements]/4 seems to be self contradictory.

Background:

Since set iterators are constant iterators, it is common practice to
either make non-key fields mutable or to use const_cast on *i.

Problem description:

The first sentence of 24.1/4 states that *i behaves as a reference to
const.  This supports the above practice as well as T const* = &*i.
The second sentence seems to say otherwise.

  Constant iterators do not satisfy the requirements of output
  iterators, and the result of the expression *i (for constant
  iterator i) cannot be used in an expression where an lvalue
  is required.

The last part has been interpreted to allow *i being an rvalue which
prevents all of the above practices.

Recommended Resolution:

Change the last part of the sentence to read

  in an expression where a modifiable lvalue is required.
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]