|
Boost : |
From: Thomas Witt (witt_at_[hidden])
Date: 2005-11-18 13:53:11
Orjan Westin wrote:
> I have a question on the indirect_iterator, and what related standards say.
There is no standard that covers indirect_iterator as such.
>
> 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();
int main()
{
std::string s("Foo");
std::vector<std::string*> rgP;
rgP.push_back(&s);
boost::make_indirect_iterator(rgP.begin())->clear();
std::cerr << s << '\n';
}
Works for me what did I miss?
>
> Does anybody know if it does say anything on this subject, and why
> operator->() wasn't included in indirect_iterator?
It would be helpful if you would include compiler/platform boost version
in your report.
Regards
Thomas
-- Thomas Witt witt_at_[hidden]
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk