Inability to explicitly specialize a template class within another non-specialized template class

Discussion in 'C++' started by jn@ngedit.com, Feb 17, 2006.

  1. Guest

    Hi everyone,

    I was trying to implement a design when I've found what seems a
    limitation of standard C++. I can't specialize an inner class in this
    way:

    template <class ARG>
    template <>
    class Outer<ARG>::Inner<int>
    {
    //...
    };

    Actually, I was doing something more complex, in which the explicit
    specialization was not on 'int', but on Outer<ARG>, so actually I was
    trying to provide an explicit specialization for the case when the
    argument to the inner template matched the outer one.

    I will be working around this with a kludge, performing several
    fully-explicit specializations for each of he different ARG's involved
    (there are only 2 now and there will be 4 or 5 later on). But, I'd like
    to know whether there is any construct in C++ by which I can detect
    matching template arguments and provide a specialization in that case
    -- maybe that way I'd be able to use a better hack^H^H^H^H workaround.

    Thanks in advance,

    J
     
    , Feb 17, 2006
    #1
    1. Advertising

  2. Re: Inability to explicitly specialize a template class within anothernon-specialized template class

    wrote:
    > I was trying to implement a design when I've found what seems a
    > limitation of standard C++. I can't specialize an inner class in this
    > way:
    >
    > template <class ARG>
    > template <>
    > class Outer<ARG>::Inner<int>
    > {
    > //...
    > };
    >
    > [..]


    Yes, to explicitly specialise a member you need to first explicitly
    specialise the outer template. That's a requirement of the language.

    V
    --
    Please remove capital As from my address when replying by mail
     
    Victor Bazarov, Feb 17, 2006
    #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. Old Wolf
    Replies:
    4
    Views:
    390
    Victor Bazarov
    Apr 8, 2005
  2. BigMan
    Replies:
    3
    Views:
    1,436
    BigMan
    Apr 22, 2005
  3. mrstephengross
    Replies:
    1
    Views:
    287
    Victor Bazarov
    Aug 2, 2005
  4. Aarti
    Replies:
    2
    Views:
    2,282
    Aarti
    Jul 12, 2007
  5. Replies:
    3
    Views:
    458
Loading...

Share This Page