Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > partial specialization of templates

Reply
Thread Tools

partial specialization of templates

 
 
Shekhar
Guest
Posts: n/a
 
      04-08-2004
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
 
Reply With Quote
 
 
 
 
Alf P. Steinbach
Guest
Posts: n/a
 
      04-08-2004
* (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.

--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
nested templates and partial specialization ld C++ 8 11-12-2011 03:18 PM
how to Specializations of function Templates or Overloading Function templates with Templates ? recover C++ 2 07-25-2006 02:55 AM
VC 2005 - templates - partial specialization VB C++ 2 06-26-2006 03:57 PM
template specialization overriding non-specialization? Joseph Turian C++ 2 04-16-2006 02:46 PM
Templates templates templates JKop C++ 3 07-21-2004 11:44 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57