partial specialization of templates

Discussion in 'C++' started by Shekhar, Apr 8, 2004.

  1. Shekhar

    Shekhar Guest

    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
     
    Shekhar, Apr 8, 2004
    #1
    1. Advertising

  2. * (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?
     
    Alf P. Steinbach, Apr 8, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. JKop
    Replies:
    3
    Views:
    479
  2. Joseph Turian
    Replies:
    2
    Views:
    468
  3. VB
    Replies:
    2
    Views:
    463
  4. recover
    Replies:
    2
    Views:
    812
    recover
    Jul 25, 2006
  5. ld
    Replies:
    8
    Views:
    316
Loading...

Share This Page