Boost logo

Boost Users :

Subject: Re: [Boost-users] boost::bond and assignment
From: michi7x7 (mailing-lists_at_[hidden])
Date: 2010-09-17 11:51:24


> Hello,
Hi,
>
> I have to write a simple loop whihc assigns a member variable to a
> constant value,
>
> vector<boost::shared_ptr<clss> > tmp
>
> for(size_t i=0; i<tmp.size(), i++)
> tmp[i]->mem = 0.0;
>
> How this can be done using stl algorithms and boost::bind?
Use Boost.Lambda for this:

std::vector<boost:shared_ptr<class>> tmp;
std::for_each(tmp.begin(), tmp.end(), _1 = 0);

http://www.boost.org/doc/libs/1_44_0/doc/html/lambda/using_library.html#lambda.introductory_examples

Regards,

michi7x7



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