Hi can anyone please explain what is the correct syntax for partial specialization of template template? or is it even possible? any help is much appreciated
template < typename A >
class X
{
};
template < typename B >
class Y
{
};
template < template< typename > class U, class T >
class Z
{
// there are other methods in class which i don't want to replicate
void func(); // want to specialize this for class X
};
template < template< typename > class U, class T >
void Z< U, T >::func()
{
std::cout << " this is done ";
}
// specialize this for X
template < template< typename > class U, class T >
void Z< X, T >::func()
{
}
You cannot specialise just a part of a class template. When you partially specialise a class template, you need to provide the entire declaration, not just a single function.
And you cannot partially specialise a function template.
You might be able to do what you want with inheritance. You could collect the shared methods in a base class, and then define a templated derived class with a partial specialisation for the methods with exceptions.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.