Problem with boost::bind, boost::shared_ptr and std::find_if algorithm

All, I have the following data sructure: struct WeightedTimeHolder { double time; double dt; double weight; double dailyVol; double varDelta_t; double cutToCutdailyVol; double extraVar; double varPlusEventVar; double aggrVar; double implVol; int cut; } and typedef multimap<int, boost::shared_ptr<WeightedTimeHolder> > DataMap. Now given value of cut in this data structure I would like to find the next position in DataMap which corresposnds to this gven value, I do it in the following manner: void nextPositionForCut(DataMap::iterator& pos, CutOffType cut) const { if((*pos).second->cut!=cut) while((*(++pos)).second->cut!=cut && pos!=m_pData->end()) {} // convert to boost::bind for better use! //pos = find_if(pos, m_pData->end(), boost::bind(&DataMap::value_type::second::value_type::cut, _1) == cut); } Since this looks really ugly I would like to ask you how this can be converto to find_if algorithm with a little help of boost::bind. I tried but could not succees. Thanks for help, Przemyslaw ___________________________________________________________ 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.

Hi Przemyslaw, On Tue, Aug 3, 2010 at 7:34 AM, <przemyslaw.sliwa@uk.bnpparibas.com> wrote:
All,
<snip code>
Since this looks really ugly I would like to ask you how this can be converto to find_if algorithm with a little help of boost::bind. I tried but could not succees.
It seemed necessary to add a nested bind call. #include "boost/bind.hpp" #include "boost/shared_ptr.hpp" #include <map> struct WTH { int cut; }; int main() { int cut; typedef std::multimap<int, boost::shared_ptr<WTH> > DataMap; std::find_if(myMap.begin(), myMap.end(), boost::bind(&WTH::cut, boost::bind(&DataMap::value_type::second, _1)) == cut); return 0; } HTH, Nate
participants (2)
-
Nathan Crookston
-
przemyslaw.sliwa@uk.bnpparibas.com