Topic: local Template classes


Author: Thanatos <fvali@biotrack.com>
Date: 1998/11/05
Raw View
Does standard C++ allow nested classes within local classes to be
templates.
I know in the standard it states that template declarations must have
either namespace or class scope, so technically it sounds like local
nested templates are standard.
In addition the standard also states, if i remember correctly, that
nested classes within local classes are also local classes; thus, by
that definition we can actually have local class templates, right?

(Any references to the standard will be appreciated :-))
So is this standard C++:

template <class T>  const T f()
{
   struct Local
   {
       template<class T_> struct InnerLocal {  };
   };
   return T();
}

And if this is well-formed, what is the reasoning behind not allowing
this:
template<class T>  const T f()
{
   template<class T_> struct Local { };
   return T();
}

Also now regarding member templates in local classes, I think the
standard prohibits this:
void f()
{
   struct Local
   {
       template<class T>  T f() { return T(); }
   };
}
and this too, right? (since local inners are locals too)
void f()
{
   struct Local
   {
       struct Inner
       {
          template<class T>  T f() { return T(); }
       };
   };
}

Why are local member templates prohibited?

-thanks
-fais








--
Faisal Vali  fvali@biotrack.com
Software Engineer Identix Biometric Security
WWW: http://www.identix.com
-------------------------------------------------------
Imagination is a quality given a man to compensate him for what he is
not, and a sense of humor was provided to console him for what he is.
(Oscar Wilde)
---
[ 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              ]