The short answer is no. Casting is legal, but the only thing you can do with the results is to return them to the original type. The arguments by default do not change the signature function. They are only counted on the call site, where they are transferred if the client does not provide an argument. the function itself is always called with a full set of arguments, which obviously will not happen if you call it based on the results of the actors.
The usual answer here, if you have control over the sources, is to use overloading instead of the default arguments. (I heard the arguments that you should always use overloading instead of the default arguments.) So
void originalFunction1( int a ) { ... } void originalFunction1() { originalFunction1( 0 ); }
instead of what you have.
In addition, you can play games with templates:
template <typename FunctionPtr> void overloadedFunction( FunctionPtr fptr ) { fptr(); }
I would prefer the first solution if you can use it.
source share