partial specialization of templates

S

Shekhar

template<typename T> struct A{}; //line 1
template<typename T> struct B{}; //line 2
template<typename T> struct B<A<T> > {}; //line 3: partial
specialization of B

VC6.0 compiler results for the above:
at line 3:

error C2989: 'B<struct A<T> >' : template class has already been
defined as a non-template class
error C2988: unrecognizable template declaration/definition

Is there anyway to achieve the above without using partial
specialization of templates

Regards
Shekhar
 
A

Alf P. Steinbach

* (e-mail address removed) (Shekhar) schriebt:
template<typename T> struct A{}; //line 1
template<typename T> struct B{}; //line 2
template<typename T> struct B<A<T> > {}; //line 3: partial
specialization of B

VC6.0 compiler results for the above:
at line 3:

error C2989: 'B<struct A<T> >' : template class has already been
defined as a non-template class
error C2988: unrecognizable template declaration/definition

Is there anyway to achieve the above without using partial
specialization of templates

Not in general, but there are tricks for special cases, essentially
replacing partial specialization by nested full specialization. Which
depends on the usage context. I suggest looking in the source code for
the VC 6.0 port of the Loki library.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top