-----Original Message----- From: Douglas Gregor [mailto:gregod@cs.rpi.edu] Sent: Friday, August 09, 2002 3:32 PM To: Boost-Users@yahoogroups.com Subject: Re: [Boost-Users] Getting the hang of Boost::Bind
On Friday 09 August 2002 06:08 pm, Tom Matelich wrote:
I have a vector of
class Landmark { public: std::string const& getName() const; ... };
I want to do a find_if for a name that I have.
something like std::find_if(begin, end, boost::bind(std::equalstd::string(???, name_to_find)));
What do I put for the ??? ?
I presume that [begin, end) is an iterator sequence of Landmark instances? Then ??? = boost::bind(&Landmark::getName, _1), meaning that the first parameter to std::equalstd::string::operator() is a call to Landmark::getName where the object parameter (this) is the first argument (_1) to the bind function object.
Thanks for the quick reply. That's what I thought. To make things more
concrete...
std::vector<Landmark> v;
...
std::vector<Landmark>::const_iterator iter =
std::find_if(v.begin(), v.end(),
boost::bind(std::equalstd::string,
boost::bind(ZLandmark::Landmark::getName, _1),
name_to_find));
Is what I think you're telling me. Perhaps I should mention now that I am
using VC6. Compiling the above line I get many errors, here are the first
three:
inspdoc.cpp(453) : error C2780: 'class boost::_bi::bind_t
__cdecl boost::bind(R (__thiscall T::*)(B1,B2,B3,B4,B5,B6,B7, B8) const,A1,A2,A3,A4,A5,A6,A7,A8,A9)' : expects 10 arguments - 3 provided c:\dev\opt\include\boost/bind/bind_mf_cc.hpp(223) : see declaration of 'bind' inspdoc.cpp(453) : error C2780: 'class boost::_bi::bind_t
,class boost::_bi::list9 __cdecl boost::bind(R (__thiscall T::*)(B1,B2,B3,B4,B5,B6,B7,B 8),A1,A2,A3,A4,A5,A6,A7,A8,A9)' : expects 10 arguments - 3 provided c:\dev\opt\include\boost/bind/bind_mf_cc.hpp(212) : see declaration of 'bind'
Oh, and I guess that should be std::equal_to, right? Didn't work either though. Thanks, Tom PS Unfortunately, I have to run. I'll be looking at this again this weekend though. ----------------------------------------------------------------------- DISCLAIMER: Information contained in this message and/or attachment(s) may contain confidential information of Zetec, Inc. If you have received this transmission in error, please notify the sender by return email. -----------------------------------------------------------------------