template <class T1, class T2>
class A {};
template <class T1>
class A {};
A<int, int> a;
A<int> b;
This code generates
error C2976: 'A' : too few template arguments
at the second diclaration of 'A' class.
Your first declaration defines a class A
with 2 template arguments. Anything after that must either be a specialization of that or some other enabled version.
If you want to allow either 1 or 2 template arguments you can use variadic templates as follows:
template <class... Args>
class A;
template <class T1, class T2>
class A<T1, T2> {};
template <class T1>
class A<T1> {};
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments