Aug 9, 2012 at 5:16pm UTC
Hi!
I need to specialize a template with a specific template class.
This works:
template <typename T>
class B
{
};
template <typename T>
class A
{
public:
void value()
{
std::cout << "standard" << std::endl;
}
};
template <>
class A<B<int> >
{
public:
void value()
{
std::cout << "spec" << std::endl;
}
};
int main()
{
A<int> a;
A<B<int> > b;
a.value();
b.value();
return 0;
}
But I need the template parameter for class B in the specialized version, something like this:
template <>
class A<template <typename T> B<T> >
{
public:
void value()
{
std::cout << "spec" << std::endl;
}
};
I've got the following error:
template argument 1 is invalid
Any help is appreciated:
Imre Horvath
Aug 9, 2012 at 6:43pm UTC
Thank you for your answer.
The problem is, I want specialization only for templates with template parameter of type B.
If I create a class:
template <typename T>
class C
{
};
A<C<int> > also is the specialized tempalte like A<B<int> >, not the standard.
Imre
Aug 9, 2012 at 7:08pm UTC
I think this is it.
Thank you:
Imre