Re: [Boost-users] boost::bond and assignment

Thanks for help, but I want to assign the value of the member variable not the pointer itself: vector<boost::shared_ptr<clss> > tmp for(size_t i=0; i<tmp.size(), i++) tmp[i]->mem = 0.0; In this case clss::mem should be changed, I get an error doing std::for_each(tmp.begin(), tmp.end(), &_1::mem = 0); Can this be done? Thanks for help ___________________________________________________________ This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and delete this e-mail. Any unauthorised copying, disclosure or distribution of the material in this e-mail is prohibited. Please refer to http://www.bnpparibas.co.uk/en/information/legal_information.asp?Code=ECAS-8... for additional disclosures.

Below gives a couple ways you could achieve what you want: #include <boost/iterator/indirect_iterator.hpp> #include <boost/lambda/lambda.hpp> #include <boost/make_shared.hpp> #include <vector> int main() { std::vector<boost::shared_ptr<int> > tmp(5, boost::make_shared<int>(5)); std::for_each(tmp.begin(), tmp.end(), *boost::lambda::_1 = 0); std::fill(boost::make_indirect_iterator(tmp.begin()), boost::make_indirect_iterator(tmp.end()), 0); } HTH, Nate
participants (2)
-
Nathan Crookston
-
przemyslaw.sliwa@uk.bnpparibas.com