Topic: 24.1/4 self contradictory?


Author: jpotter@falcon.lhup.edu (John Potter)
Date: 2000/05/31
Raw View
Using a vector as a simple example of any container.

vector<int> const vc(10, 40);

| Besides its category, a forward, bidirectional, or random access
| iterator can also be mutable or constant depending on whether the
| result of the expression *i behaves as a reference or as a
| reference to a const.

Behaves as?  Is?  For mutable iterators, table 74 states the the
return of the expression *i is T&.  Does it follow that for constant
iterators, the expression *i returns T const&?.  In any case,
since *i behaves as a reference to a const the following is valid.

    int const* icp(&*vc.begin());

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

But the above expression (&) requires an lvalue.

Should that read "where a modifiable lvalue is required" or do I
need another reading lesson?

For constant iterators must the result of *i be a T const& or
could it be a T?

John

---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html              ]