Suppose I have a boost :: function with an arbitrary signature of type CallbackType .
- Is it possible to use
boost::bind to create a function that takes the same arguments as CallbackType but calls two functors in sequence?
I am open to any potential solution, but here ...
... A hypothetical example using some magic pattern:
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; }
c ++ boost callback functor bind
Catskul
source share