Can the types of parameters in template functions be inferred?
问题 I'm writing some template functions in C++, but I'm not sure if it's possible to define a template function that infers the types of its parameters. I tried to define a template with inferred parameter types, but this example won't compile: template <auto> auto print_stuff(auto x, auto y) { std::cout << x << std::endl; std::cout << y << std::endl; } It works when I give a unique name to each parameter type, but this seems somewhat redundant: #include <iostream> #include <string> template