Hello there,
I've started using boost function and bind features , and I'd like to find a
way to do the following. You can take it as suggestion, if it is not
implemented :)
I would like to use the bind function on object members in the same way
indipendently of the number of arguments.
For example:
function FunctionOne;
function < bool (int ) > FunctionTwo;
class Implementor
{
public:
void ImplOne ( int , int );
bool ImplTwo ( int );
};
void test ()
{
Implementor i;
FunctionOne = bind ( &Implementor::ImplOne , &i , _1 , _ 2);
FunctionTwo = bind (&Implemenetor::ImplTwo, &i , _1);
/* I Would be nice to do something like this, with parameter "guessing"
*/
// FunctionOne = GenericBind ( &Implementor::ImplOne ,&i);
// FunctionTwo = GenericBind ( &Implementor::ImplTwo, &i);
/* This will greatly remove verbosity! */
/* Actually I do */
#define Bind0(A,B) bind(A,B)
#define Bind1(A,B) bind(A,B,_1)
#define Bind2(A,B) bind(A,B,_1,_2)
......
FunctionOne = Bind2 ( &Implementor::ImplOne , &i );
FunctionTwo = Bind1 ( &Implementor::ImplTwo , &i);
}
It would be usefoul to make library callbacks more usable, insteat of
writing a long list of arguments each time.
It is possible with current implementation?
I ask you for any suggestion,
Thank you
QbProg