Boost logo

Boost :

From: Orjan Westin (orjan.westin_at_[hidden])
Date: 2005-11-18 08:09:34


I have a question on the indirect_iterator, and what related standards say.

I assume this class is primarily aimed for use in algorithms, which is fine.
An algorithm typically dereference an iterator to do its thing, be it
comparing or passing the dereferenced iterator on to a function or functor.
This is great.

But it doesn't handle direct usage well.

If I have an indirect_iterator i for, say, a pointer to std::string, I
cannot treat it as any other iterator to string and empty the string with
this call:
i->clear();
because the pointer operator is not changed.
Instead you have to dereference it and use it as a reference:
(*i).clear();

It seems strange to me that one way of getting hold of the iterated object
is provided, but not the other. I couldn't find anything about this in a
brief look through the standard, but I would expect it to want iterators
yield the same results for both formats.

Does anybody know if it does say anything on this subject, and why
operator->() wasn't included in indirect_iterator?

Cheers,
Orjan


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