 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
ramdesi Guest
|
Posted: Wed Nov 23, 2005 1:52 pm Post subject: Using bind |
|
|
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
|
Posted: Wed Nov 23, 2005 5:52 pm Post subject: Re: Using bind |
|
|
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
|
Posted: Wed Nov 23, 2005 5:54 pm Post subject: Re: Using bind |
|
|
"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 |
|
 |
|
|
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
|
|