C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Using bind

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated)
View previous topic :: View next topic  
Author Message
ramdesi
Guest





PostPosted: Wed Nov 23, 2005 1:52 pm    Post subject: Using bind Reply with quote



Is there a way to use boost bind to bind more than one member function
in a stl algorithm ?
I am trying to accomplish the following:

class X {
public:
:
bool addr_match(addr_type addr);
bool state_match(state_type state);
private:
addr_type addr;
state_type state;
};

vector<X> V;
find_if(V.begin(), V.end(),
some_way_to_return_true_if_both_addr_&_state_match);

Thanks


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
Maxim Yegorushkin
Guest





PostPosted: Wed Nov 23, 2005 5:52 pm    Post subject: Re: Using bind Reply with quote




ramdesi wrote:
Quote:
Is there a way to use boost bind to bind more than one member function
in a stl algorithm ?

[]

Not sure about bind, but you can certaily do that with boost::lambda.
The resulting mess might make you consider simple and clear loop.


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]


Back to top
Jeff Flinn
Guest





PostPosted: Wed Nov 23, 2005 5:54 pm    Post subject: Re: Using bind Reply with quote




"ramdesi" <vaidya.ramanan (AT) gmail (DOT) com> wrote

Quote:
Is there a way to use boost bind to bind more than one member function
in a stl algorithm ?
I am trying to accomplish the following:

class X {
public:
:
bool addr_match(addr_type addr);
bool state_match(state_type state);
private:
addr_type addr;
state_type state;
};

vector<X> V;
find_if(V.begin(), V.end(),
some_way_to_return_true_if_both_addr_&_state_match);

With boost.bind 1.33.1:

using boost::bind;

find_if
( V.begin(), V.end()
, bind( &X::addr_match, _1, some_addr )
&& bind( &X::state_match, _1, some_state )
);

Jeff Flinn



[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]


Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.