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. Advertisements

  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. Advertisements

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. Chandra Shekhar Kumar

    template partial specialization

    Chandra Shekhar Kumar, Jun 24, 2003, in forum: C++
    Replies:
    17
    Views:
    3,212
    tom_usenet
    Jun 25, 2003
  2. Philip Lawatsch

    Partial Specialization workaround

    Philip Lawatsch, Jul 16, 2003, in forum: C++
    Replies:
    9
    Views:
    534
    Philip Lawatsch
    Jul 16, 2003
  3. Alexander Stippler

    partial specialization of function template

    Alexander Stippler, Aug 15, 2003, in forum: C++
    Replies:
    1
    Views:
    622
    Rob Williscroft
    Aug 15, 2003
  4. JKop
    Replies:
    3
    Views:
    690
  5. Joseph Turian
    Replies:
    2
    Views:
    688
  6. VB
    Replies:
    2
    Views:
    613
  7. recover
    Replies:
    2
    Views:
    1,067
    recover
    Jul 25, 2006
  8. ld
    Replies:
    8
    Views:
    478
Loading...