Boost logo

Boost :

From: jsiek_at_[hidden]
Date: 1999-12-07 18:29:31


Hi Dietmar,

I now understand your complaint about operator*() and proxies (or any
non-reference type). The requirements for ForwardIterator specify the
return type of operator*() to be T&. This means that the iterators in
GGCL are not completely conformant to ForwardIterator. They do not
return a reference type, they return an actual object.

I suppose this is one of the reasons that motivated you in moving away
from operator*().

I would still argue that even a non-conformant operator*() is better
than something else. First, there are already other examples in the
standard library of non-conformant forward iterators
(vector<bool>). But most importantly, the operator*() is necessary to
inter-operate with STL algorithms.

For instance, with GGCL one can write:

for_each(adj(v).begin(), adj(v).end(), print_color());

struct print_color {
  template <class Vertex>
  void operator()(const Vertex& v) {
    cout << color[v] << endl;
  }
};

This would not be possible without operator*.

And finally, I think the number of situations where the return type
not being a reference causes an error will be very small. The
sad fact of the matter is that this is a dirty little corner of
the C++ language where things didn't work out quite right.

Cheers,

Jeremy


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk