I struggle with specializations of member functions when they are templated using a variational pattern.
The following example specializes in the whole class and works great:
template<typename... Args> class C; template<class T, typename... Args> class C<T, Args...> { }; template<> class C<> { }; int main() { C<int, double> c{}; }
The following does not, although the idea behind it is exactly the same as the previous one:
class F { template<typename... Args> void f(); }; template<class T, typename... Args> void F::f<T, Args...>() { } int main() { }
I get the following error, and I do not understand because of this:
main.cpp:7:23: error: non-type partial specialization 'f<T, Args ...>' is not allowed void F::f<T, Args...>() { } ^ main.cpp:7:6: error: prototype for 'void F::f()' does not match any in class 'F' void F::f<T, Args...>() { } ^ main.cpp:3:10: error: candidate is: template<class ... Args> void F::f() void f(); ^
Are there any restrictions that I donβt know about when a function template specializes?
G ++ Version: g ++ (Debian 5.2.1-23) 5.2.1 20151028
EDIT
By the way, the actual problem I get from real code is:
non-class, non-variable partial specialization 'executeCommand<T, Args ...>' is not allowed
In any case, the above example is similar to the real one. I hope the errors are not completely unrelated.