I am using boost::function to implement closures for a Visual C++ 3rd
From: "Edward Diener"
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*/);