Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2005-11-18 19:09:47

"Orjan Westin" <orjan.westin_at_[hidden]> writes:

> 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.

It certainly is changed appropriately.

> Instead you have to dereference it and use it as a reference:
> (*i).clear();

Can you post a minimal reproducible example that shows the problem
you're describing? Your description is not consistent with the way
indirect_iterator was designed, so either something is wrong with your
example or you have found a bug in the library.

Dave Abrahams
Boost Consulting

Boost list run by bdawes at, gregod at, cpdaniel at, john at