Boost logo

Boost Users :

From: Duane Murphy (duanemurphy_at_[hidden])
Date: 2004-12-03 20:17:01


I am implementing an iterator via iterator facade. The container that the
iterator is being used with can only return dereferenced values by value
(not by reference).

If I implement the dereference() function (for facade) by returning a
value (instead of reference) then it appears that the iterator works properly.

The most important operation that does _not_ work is that the iterator
cannot be used with bind(). (bind cannot be used with non-const return types.)

If I change the iterator to return a reference type then the iterator
functions still work and so does bind.

What is the proper way of implementing an iterator with this limitation
so that it works properly with bind?

In the past, I keep a mutable value member along with the iterator to
store the last dereferenced value. Of course this is fraught with problems.

Is there an example iterator that demonstrates the proper way of doing
this? Is there some kind of proxy class that can be used to overcome this
limitation?

Thanks for your help,

 ...Duane


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net