This is the mail archive of the libstdc++@sourceware.cygnus.com mailing list for the libstdc++ project. See the libstdc++ home page for more information.
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