The question almost does not make sense without an example. So here is what I’m trying to do.
In general C++ allows the following:
template<class T, class U, T t, U u>
void func() {}
func<char, int, 'A', 10>();
But it seems like its natural variadic extension does not work.
template<class...T, T... t>
void func() {}
func<char, int, 'A', 10>();
Both clang and g++4.7 reject the above code. The error is shown where the instantiation is done. It appears to me that the two variadic lists should be parsed unambiguously because the first one has types and the other one has integral values only.
If the above is not meant to work, I think the following won’t work either.
template <class Ret, class... Args, Ret (*func)(Args...)>
class Foo {};
I think the Foo template is a rather useful thing to have.
(Extra: Directly answering your first question, you can also turn
template<class...T, T... t> void func() {}into a template-inside-a-template. This doesn’t work in g++4.6, but does in clang 3.0, hence it took me a while to find it.)Put a template inside a template:
Is a template-inside-a-template acceptable? An alternative is to use tuples with
func< tuple<char,int> , make_tuple('A',10) >. I think this is doable, but you might have to roll your own tuple class (it appears that make_tuple isn’t aconstexpr.Finally, you might be able to implement your Foo template as follows:
This latter code is on ideone. To demonstrate, I implemented a constructor to forward the args to the function that’s code into the template.