I have a function which takes two std::functions as arguments. The parameter of the second function has the same type as the result of the first.
I wrote a function template like this:
template<typename ResultType>
void examplFunction(std::function<ResultType()> func, std::function<void(ResultType)> func2) {
auto x = func();
func2(x);
}
I can call it with:
void f() {
examplFunction<int>([]() { return 1; }, //
[](int v) { std::cout << "result is " << v << std::endl; });
}
Is there a way to to get rid of the <int> at examplFunction<int> and let the compiler deduce the type of ResultType?