Bind + Function + Arguments

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

On Fri, Feb 29, 2008 at 6:08 AM, QbProg
[snip]
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 have something in the dataflow library that I am planning to take in
the direction you're suggesting. The current syntax allows something
like this:
FunctionOne = make_slot_selector

It would be really usefoul to have something like that :) Thank you QbProg
I have something in the dataflow library that I am planning to take in the direction you're suggesting. The current syntax allows something like this:
FunctionOne = make_slot_selector
( &Implementor::ImplOne , i ); FunctionTwo = make_slot_selector ( &Implementor::ImplTwo , &i); So it's not (yet) quite what you're looking for, but when the member function is not overloaded I don't think I need the signature to be specified explicitly, and can provide something like
FunctionOne = make_slot_selector( &Implementor::ImplOne , i );
But I haven't had time to try it yet :-) I was going to try to do one last push this weekend to get this lib submitted for review, maybe as a part of that effort I can give this a whirl.
Stjepan _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

On Sat, Mar 1, 2008 at 7:10 AM, QbProg
FunctionOne = make_slot_selector( &Implementor::ImplOne , i );
But I haven't had time to try it yet :-) I was going to try to do one last push this weekend to get this lib submitted for review, maybe as a part of that effort I can give this a whirl.
It would be really usefoul to have something like that :)
Thank you QbProg
OK, I have it. Here is a little snippet of usage:
class sum
{
public:
sum(int base)
: m_base(base)
{}
int add1(int num) const
{ return m_base + num; }
int add2(int num1, int num2) const
{ return m_base + num1 + num2; }
private:
int m_base;
};
...
boost::function
participants (2)
-
QbProg
-
Stjepan Rajko