specialization inside a template

Discussion in 'C++' started by Marc, Apr 22, 2011.

  1. Marc

    Marc Guest

    I am having trouble understanding why the following is forbidden:

    template<class> struct A {
    template<class>struct B;
    template<>struct B<int>{};
    template<>struct B<double>{};
    };

    while this is perfectly fine:

    template<class> struct A {
    template<class,int=0>struct B;
    template<int i>struct B<int,i>{};
    template<int i>struct B<double,i>{};
    };

    Well, I know the difference between the 2 cases, what I am interested
    in is the reason that led to standardize things this way (I'd be happy
    to learn it is just lack of interest).

    Workarounds can be painful.
    Marc, Apr 22, 2011
    #1
    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. David B. Held
    Replies:
    2
    Views:
    467
    Rob Williscroft
    Oct 26, 2003
  2. Dave
    Replies:
    4
    Views:
    7,664
    pdixtl
    Jun 4, 2010
  3. Joseph Turian
    Replies:
    2
    Views:
    463
  4. Replies:
    7
    Views:
    567
  5. Replies:
    6
    Views:
    3,856
Loading...

Share This Page