Topic: Class template members of a class


Author: Alexandre Oliva <oliva@dcc.unicamp.br>
Date: 1998/06/28
Raw View
Gregory Bond <gnb@itga.com.au> writes:

> it seems member classes and local-to-a-function classes are not
> permitted to be templates.

You cannot declare templates in function scope, but you can declare
them in class scope:

class foo {
  template <typename T> class member_template;
};

// then, in the implementation file:

template <typename T> class foo::member_template<T> {
  //...
}

--
Alexandre Oliva
mailto:oliva@dcc.unicamp.br mailto:aoliva@acm.org
http://www.dcc.unicamp.br/~oliva
Universidade Estadual de Campinas, SP, Brasil
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]





Author: Gregory Bond <gnb@itga.com.au>
Date: 1998/06/27
Raw View
I have a class template that uses another class template as an
implementation trick (to do compile-time 10^x).  In order to reduce
the namespace pollution this second template should orta be private to
the class or even to this particular function, but it seems member
classes and local-to-a-function classes are not permitted to be
templates (irrespective of whether the parent class is a template or
not).

Is this conclusion correct?  If so, given the lack of namespaces, how
do I hide this template given that it really is only needed by one function?

If not, how do I write it?  Extra bonus points: how do I write it so
the body if the internal class template is only defined in the
implementation file of the parent class?


--
Gregory Bond                            ITG Australia Ltd, Melbourne, Australia
<mailto:gnb@itga.com.au>                           <http://www.bby.com.au/~gnb>
From: bruce@itga.com.au (Do not use this address.  It catches junk email.)
From: bruce@bby.com.au, bruce@melba.bby.com.au  (So do these ones)
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]