How can I template these functions?
boost::function< void(int) > binder( void(*func)(int, char), int a1, char a2 )
{
return boost::bind( func, a1, a2 );
}
void proxy( boost::function< void(int) > func, int a1 )
{
boost::bind( func, a1 )();
}
I tried the following with no success:
template< typename R, typename A1, typename A2 >
static boost::function< void(int) > binder( R(*func)(A1,A2), A1 a1, A2 a2 )
{
return boost::bind( func, a1, a2 );
}
template< typename A1 >
static void proxy( boost::function< void(A1) > func, A1 a1 )
{
boost::bind( func, a1 )();
}
It would be nice if I could do without binder(). This is how I intend to use them:
void print( int i, char c );
boost::signals2::signal.connect(
boost::bind(
&proxy,
boost::bind(
&binder,
&print,
_1,
'a'
),
_1
)
);
I checked out the following with no luck:
how-to-use-manipulate-return-value-from-nested-boostbind
perform-argument-substitution-on-nested-boostbind-without-composition