问题几乎没有意义。 因此,我试图这样做。
总的来说,C++允许:
template<class T, class U, T t, U u>
void func() {}
func<char, int, A , 10>();
但是,似乎自然的理论延伸并不奏效。
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 {};
我认为,“Foo”模板是一个非常有用的东西。