You cannot do this. You will need to modify func
to take the function object first. Sort of:
int func( int a, std::function< int(int, int) > b ) { return b( a, rand() ); }
Actually there is no need for b
be std::function
, it could be instead of templates:
template< typename T > int func( int a, T b ) { return b( a, rand() ); }
but I would stick with the std::function
version for clarity and somewhat less confusing compiler output on errors.
Then you can do something like:
int i = func( 10, std::bind( &c, _1, _2, some-value ) );
Note that this is C ++ 11 , but you can do it in C ++ 03 using Boost.
source share