Given the following variadic template:
template<typename... Params>
void fun(void(*f)(Params...), Params... params) {
f(params...);
}
int main() {
fun(+[](int a, int b) {}, 2, 3);
}
For now when invoking fun
with a lambda I need to specify types of all lambda arguments explicitly. It seems redundant since the int, int
could be deduced from 2, 3
. Is there a way to make it more concise and automatic?
I would like the following to work, but it doesn't:
template<typename... Params>
void fun(void(*f)(Params...), Params... params) {
f(params...);
}
int main() {
fun(+[](auto a, auto b) {}, 2, 3);
}
I am compiling with g++ 5.4.0
and -std=c++14
.