
30 Nov
2010
30 Nov
'10
6:16 p.m.
przemyslaw.sliwa@uk.bnpparibas.com wrote:
Hello,
I would like to replace this trivial loop
for(size_t i=0; i
event(domCcy, intersection[i])); } with a call to std::transform and boost::bind. The events object is actually a boost_shared_ptr<> of a certain type. domCcyEventPtrs and intersection are std::vector<> objects. Can this be done?
std::transform ( intersection.begin() , intersection.end() , std::back_inserter(domCcyEventPtrs) , boost::bind(&events_type::event, &events, domCcy, _1) ); depending on what domCcy is and how you want it passed you may need to wrap it in boost::ref or boost::cref. Also a more succinct approach would be to use the range library. Jeff