David Abrahams wrote:
Peter Dimov wrote:
David Abrahams wrote:
Duane Murphy wrote:
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.)
Sorry, I can't imagine what you mean. Of course bind works with non-const return types: [...]
Probably the following:
std::for_each( first, last, boost::bind( f, _1 ) );
When *first returns a non-const rvalue, bind can't take it.
I guess the answer is to make the reference type const, then.
That will suppress the iterator's writability, though. I hope it's desired. -- Dave Abrahams Boost Consulting http://www.boost-consulting.com