18 Aug
2009
18 Aug
'09
10:01 a.m.
Hello Neil,
Two tactics spring to mind.
One is to use boost::make_indirect_iterator on v.begin() and v.end() and just pass in f instead of the boost::bind(...).
Yes, this makes for quite readable code: for_each(make_indirect_iterator(vec.begin()), make_indirect_iterator(vec.end()), &foo);
The other is to use RangeEx (shameless plug) thus:
using namespace boost::adaptors; boost::for_each(v | indirected, f);
Creative! A good example of why it helps to have many power tools! Cheers, Bjorn Karlsson www.skeletonsoftware.net