Boost logo

Boost Users :

From: Christoph Duelli (duelli_at_[hidden])
Date: 2008-03-20 04:32:20


Please consider the following scenario:

class Caller
{
public:
   Caller(...);
   typedef boost::function<void (int)> MyCallback;
   MyCallback callback;
};

class Callee
{
public:
   Callee();
   void do_it() {...};
};

Caller caller;
Callee callee;
// does not work as do_it does not match MyCallback
caller.callback = boost::bind(&Callee::do_it, &callee, ...);

The function do_it() is not interested in the arguments passed to the
callback. I obviously could make the function take these arguments and just
ignore them... but I was wondering: is it possible to leave do_it() as it
is and work some magic with Boost.Bind that 'drops' the unwanted argument?
Basically create an anonymous function object that calls callee without the
argument it gets passed itself.
(Similarly to Qt signals/slots: the slot may have fewer arguments than the
signal.)

Thank you and best regards
Christoph


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