template specialization with template class

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
Use this syntax:
1
2
3
4
template<template <typename> class B, typename T>
class A<B<T> >
{
//etc. 
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
Maybe partial specialization

1
2
3
4
5
6
7
template <typename T> 
class A < B<T> >
{
    
   

};
I think this is it.

Thank you:
Imre
Topic archived. No new replies allowed.