What is the correct syntax to fully specialize a template class, to an already defined specialization?
E.g., in the code below, how can I declare A<2>
as an alias to A<0>
?
template <int I>
struct A;
template <>
struct A<0> { int x; };
template <>
struct A<1> { int y; };
template <>
using A<2> = A<0>; // error: expected unqualified-id before 'using'
Note: for the code above, it would be enough to specialize A<1>
and define the non-specialized A
like A<0>
:
template <int I>
struct A { int x; };
template <>
struct A<1> { int y; };
but this would not work if you a more complex situation, where for a set of values you have a specialization, for another set of values another specialization, etc...