Boost logo

Boost Users :

Subject: Re: [Boost-users] [bind] How do I....?
From: Björn Karlsson (Bjorn.Karlsson_at_[hidden])
Date: 2009-08-18 06:01:47


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


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net