A
Agent Mulder
Hi group,
I have a problem with partial template specialization. In the code
below I have a template struct Music with one method, play(),
and three kinds of music, Jazz, Funk and Bach. When I specialize
Music<Bach>, I expect that the original play() method is available
in the specialization, but it is not. How can I fix this?
-X
struct Jazz{};
struct Funk{};
struct Bach{};
template<struct A>struct Music{void play(){}};
struct Music<Bach>{}; //partial template specialization
int main()
{
Music<Jazz>().play(); //OK
Music<Funk>().play(); //OK
Music<Bach>().play(); //error, Music<Bach>().play not declared
return 0;
}
I have a problem with partial template specialization. In the code
below I have a template struct Music with one method, play(),
and three kinds of music, Jazz, Funk and Bach. When I specialize
Music<Bach>, I expect that the original play() method is available
in the specialization, but it is not. How can I fix this?
-X
struct Jazz{};
struct Funk{};
struct Bach{};
template<struct A>struct Music{void play(){}};
struct Music<Bach>{}; //partial template specialization
int main()
{
Music<Jazz>().play(); //OK
Music<Funk>().play(); //OK
Music<Bach>().play(); //error, Music<Bach>().play not declared
return 0;
}