I want to pass lambda function with capture to another normal function f
.
I have found only two alternatives :-
1. pass lambda function directly, using template
template<typename Lam> f(Lam lam, something) {...}
Disadvantage: must be in header -> slower compile time
2. convert lambda to std::function
f(std::function<void(SomePointer*)> lam, something){...}
Disadvantage: execution cost is more (+100% for my case, optimized)
I want to pass many lambda functions that share the same signature to f
(good for 2).
f
is a complex function with long code. (also good for 2).
Question
Is there any technique that have advantage from both solutions?
This link Using lambda as an argument : std::function or template? vaguely said the answer is no.