|
Boost Users : |
Subject: [Boost-users] Comparing boost bind object with a pointer to member function
From: jej (ed.jung_at_[hidden])
Date: 2010-08-30 16:09:56
Hello,
Is is possible to compare a pointer to member function with a function
object returned by boost bind? I have a class with several different
functions; for each member function I use boost bind to bind the function
object to several args. At the point where I want call the function object,
I would like to check which member function it's been bound to, and decide
whether or no it should be executed.
For example, I would like the second comparison in the code snippet below to
return "Bind match." For any other member function of foo it should return
"Bind not match."
Thanks.
int main(int, char**)
{
Data d(1, 2);
Foo fx, fy;
//typedef void (Foo::*foofunctwo_t)(const Data&);
//foofunctwo_t del1 = &Foo::FuncTwo;
boost::function<void (Foo*, const Data&)> bf(&Foo::FuncTwo);
if(bf == &Foo::FuncTwo)
{
cout << "match" <<endl;
}
else
{
cout << "no match" << endl;
}
boost::function<void (const Data&)> boundfunc =
boost::bind(&Foo::FuncTwo, &fx, _1);
if(boundfunc == &Foo::FuncTwo)
{
cout << "Bind match" << endl;
}
else
{
cout << "Bind not match" << endl;
}
return 0;
};
-- View this message in context: http://old.nabble.com/Comparing-boost-bind-object-with-a-pointer-to-member-function-tp29576700p29576700.html Sent from the Boost - Users mailing list archive at Nabble.com.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net