That code doesn't compile |
Right, sorry. See the edited post above for one potential fix.
1. What is wrong with my initial example? Why does it give those errors |
Consider the recursive call
ProcessInstantiation<Classes...>();
When
Classes is an empty pack, the call expands to
ProcessInstantiation<>();
This is a call to a particular function template - the nontemplate function isn't an option. The only choice is the function template with one or more one argument that isn't provided explicitly and can't be deduced, hence the error.
2. Why are you wrapping them in structs? Is this necessary? |
It's not strictly necessary in this case.
However, using class types allows us to work around the inability to partially specialize function templates, and avoids some surprising behavior (see:
http://www.gotw.ca/publications/mill17.htm ) when full specializations are involved. A typical claim is that it's bad practice to specialize function templates.
In general, working with classes also offers the highly useful ability to pass around overload sets (using the term loosely), as discussed here
http://www.cplusplus.com/forum/general/244823/
Good rationale for a specific example (C++14's
transparent operator function objects) is given by n3421:
https://wg21.link/n3421
3. What if I wanted to do this with member functions of a class? |
I think I'm misunderstanding the question: doesn't my first example use member functions?