|
Boost Users : |
From: Peter Dimov (pdimov_at_[hidden])
Date: 2002-07-19 07:13:09
From: "Edward Diener" <eddielee_at_[hidden]>
[...]
> I am using boost::function to implement closures for a Visual C++ 3rd
party
> library and suggesting boost::bind as the main way to bind member
functions
> to my boost::function implementations. I have even provided some macros
> which make binding an end user member function to the particular
> boost::function closures of my classes, using boost::bind, easier. For C++
> Builder, as you may know, Borland has a __closure addition to the C++
> language, totally non-standard C++, which makes the usage of
boost::function
> and boost::bind unnecessary.
Borland __closures are, in some ways, more convenient, but function+bind is
a more powerful mechanism. __closures need an exact signature match:
void (__closure * event) (int mode, char const * name);
class X
{
void f1(int mode, char const * name);
int f2(char const * name, int mode, void * extraData);
};
X x;
event = &x.f1; // OK
event = &x.f2; // error
In function+bind terms:
function< void, int /*mode (_1)*/, char const * /*name (_2)*/ > event;
event = bind(&X::f1, &x /*this*/, _1 /*mode*/, _2 /*name*/);
event = bind(&X::f2, &x /*this*/, _2 /*name*/, _1 /*mode*/, 0
/*extraData*/);
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