Assume that I have a boost::function of with an arbitrary signature called type CallbackType
.
- Is it possible to use
boost::bind
to compose a function that takes the same arguments as the CallbackType but calls the two functors in succession?
I'm open to any potential solution, but here's a...
...Hypothetical example using some magic
template:
Template<typename CallbackType>
class MyClass
{
public:
CallbackType doBoth;
MyClass( CallbackType callback )
{
doBoth = bind( magic<CallbackType>,
protect( bind(&MyClass::alert, this) ),
protect( callback ) );
}
void alert()
{
cout << "It has been called\n";
}
};
void doIt( int a, int b, int c)
{
cout << "Doing it!" << a << b << c << "\n";
}
int main()
{
typedef boost::function<void (int, int, int)> CallbackType;
MyClass<CallbackType> object( boost::bind(doIt) );
object.doBoth();
return 0;
}