Boost logo

Boost Users :

Subject: Re: [Boost-users] [boost::function] Is there a way to assign a generic function, regardless number of parameters?
From: Matheus Araújo Aguiar (matheus.pit_at_[hidden])
Date: 2010-01-28 11:05:14


On Thu, Jan 28, 2010 at 12:48 PM, Igor R <boost.lists_at_[hidden]> wrote:

> > What we want to do is something like is done in the asynchronous methods
> of boost::asio when passing the callback to the async operation.
>
> In asio the callback (i.e. completion handler) has very specific
> prototype, it does not accept "any number of parameters".
>

True. What i was trying to exemplify was the behavior not the implementation
itself. One case that exemplifies what I was trying to say, is that i can
declare:

*void handler1( );
void handler2(unsigned int i1, unsigned int i2, float f, char* c);*

and pass both handlers to an async function of asio and have no problem.
That's the behavior we would like to see: We pass different functions, with
different prototypes, and without declaring a specific function to receive
each different function. It would be as in:
*
*
*/* some code doing stuff ... */
*
* schedule_callback(boost::bind(callback1, parameter1,
parameter2));
*
*/* ... do some more things ... */
schedule_callback(boost::bind(&FooClass::method1, FooInstancePointer,
param1));
/* more code ... */
schedule_callback(boost::bind(callback2, param1));*

Would there be a way of implementing this kind of thing with
boost::function, declaring only one generic function *schedule_callback *wich
receives different functions with different arguments?

Thank you for your attention,

> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>

-- 
Matheus Araújo Aguiar
Computer Scientist
matheus.pit_at_[hidden]


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