I want to define a function that takes (besides its usual input arguments) a lambda function. And I want to restrict that function as far as possible (its own input- and return types).
int myfunc( const int a, LAMBDA_TYPE (int, int) -> int mylamda )
{
return mylambda( a, a ) * 2;
}
Such that I can call the function as follows:
int input = 5;
myfunc( input, [](int a, int b) { return a*b; } );
What is the correct way to define myfunc
?
And is there a way to define a default lambda? Like this:
int myfunc( const int a, LAMBDA_TYPE = [](int a, int b) { return a*b; });