Puede alguien explicar por qué son esas dos especialidades indistinguibles al compilador (gcc 4.5.1 @ Ideone)Plantilla especialización parcial
template <typename... T> struct S;
template<typename A, typename B, typename... C>
struct S<A, B, C...> {
int f() {return 1;}
};
template<typename... A, typename... C>
struct S< S<A...>, C...> {
int f() {return 2;}
};
y cuando intento crear una instancia de S<S<a, b>, a, b> o2;
compilador se queja:
prog.cpp:20:21: error: ambiguous class template instantiation for 'struct S<S<a, b>, a, b>'
prog.cpp:6:22: error: candidates are: struct S<A, B, C ...>
prog.cpp:11:33: error: struct S<S<A ...>, C ...>
prog.cpp:20:21: error: aggregate 'S<S<a, b>, a, b> o2' has incomplete type and cannot be defined
Y cuando la última especialización se cambia a:
template<typename... A, typename B, typename... C>
struct S< S<A...>, B, C...> {
int f() {return 2;}
}
todo funciona bien.
Creo que también podría agregar el código en esta publicación, ya que es muy importante para la pregunta. – UncleBens
Código @UncleBens agregado. – Predrag