Suppose I have a function that takes a null functor as an argument:
void enqueue( boost::function<void()> & functor );
I have another function that takes an int and does something internally:
void foo( int a);
I would like to nest, but not compose, together to get a functor with a signature:
boost::function<void(int)> functor
That when called with a value - say 4 - does the following:
enqueue( boost::bind(&foo, 4) )
My first attempt was as follows:
boost::function<void(int)> functor = boost::bind(&enqueue, boost::bind(&foo,_1))
This fails because bind executes the composition when nested binding is specified. foo was first called, then the void value was "returned" to the queue, which fails.
My second attempt was as follows:
boost::function<void(int)> functor = boost::bind(&enqueue, boost::protect( boost::bind(&foo, _1) ) )
This failed because enqueue accepts a null, not a unary functor.
Can I do what I'm looking for?
Additional Information: