Boost logo

Boost Users :

Subject: Re: [Boost-users] Using vectors of ptrs
From: Roman Perepelitsa (roman.perepelitsa_at_[hidden])
Date: 2009-07-17 08:47:14


2009/7/17 Robert Jones <robertgbjones_at_[hidden]>

> struct A { void a(); };
> type std::vector<boost::shared_ptr<A> > VecType;
> VecType v;
>
> for (VecType::iterator i=v.begin(); i != v.end(); ++i )
> (*i)->a();
>
> How can I write that as a for_each loop?
>

std::for_each(v.begin(), v.end(), boost::mem_fn(&A::a));

Roman Perepelitsa.



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