Boost logo

Boost Users :

From: QbProg (tholag_at_[hidden])
Date: 2008-02-29 08:08:16


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 <void (int , int ) > 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



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