With C 20, we've gained templated lambdas, great!
[]<class T>(){};
Is it possible to call a lambda callback with a template parameter, but no argument to deduce it from?
For ex,
template <class Func>
void do_it(Func&& func) {
// Call lambda with template here, but don't provide extra arguments.
// func<int>(); ?
}
do_it([]<class T>(){ /* do something with T */ });
CodePudding user response:
Is it possible to call a lambda callback with a template parameter, but no argument to deduce it from?
This is probably what you want
template <class Func>
void do_it(Func&& func) {
func.template operator()<int>();
}