This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Static data members in template declarations
- To: mark at markmitchell dot com
- Subject: Re: Static data members in template declarations
- From: Alexandre Oliva <oliva at dcc dot unicamp dot br>
- Date: 02 Nov 1998 03:04:40 -200
- Cc: egcs at cygnus dot com, stl at sgi dot com, libstdc++-v3 at cygnus dot com
- References: <199811020050.QAA18401@smtp.earthlink.net>
On Nov 1, 1998, Mark Mitchell <mark@markmitchell.com> wrote:
> template <class T> struct S { enum E { a }; static T t[a]; };
> template <class T> T S<T>::t[S<T>::a];
> The issue is whether the `a' in the first declaration is the same as
> the `S<T>::a' in the second declaration. Since the first `a' is not
> type-dependent EGCS resolves it to be the enumeration constant.
> However, in the array definition `S<T>::a' is type-dependent, and is
> not resolved. This causes the code that compares the array bounds to
> see if the redeclaration is legal to complain.
Within the scope of S<T>, `a', `S::a' and `S<T>::a' are all the same
thing, and, since t is a static member of S<T>, anything following its
name is within the scope of S<T>. Although S<T>::a is, strictly
speaking, template-dependent, there's no way to specialize S<T>::E::a
in a way that the definition of S::t still applies. Anyway, this
shouldn't make a difference: S<T>::a would be acceptable even in the
declaration of t within the template class body. The fact that it is
template-dependent doesn't make it incorrect. IMO, this code should
be accepted.
--
Alexandre Oliva
mailto:oliva@dcc.unicamp.br mailto:oliva@gnu.org mailto:aoliva@acm.org
http://www.dcc.unicamp.br/~oliva
Universidade Estadual de Campinas, SP, Brasil