I found this:
template<typename Ret, typename ...Args>
class Function {
public:
Function(Ret (*func)(Args...)): func(func) {};
Ret operator()(const Args& ...args) {
return func(args...);
}
private:
Ret (*func)(Args...);
};
void sayHello() {
std::cout << "hello" << std::endl;
}
int main() {
Function<void> fn(sayHello);
fn();
}
If I didn't provide types in the first line in the main function, it will be compile error. But, isn't the types able to be infered according to the argument of the constructor?