Static data members in template declarations

Mark Mitchell mark@markmitchell.com
Mon Nov 2 00:52:00 GMT 1998


>>>>> "Jason" == Jason Merrill <jason@cygnus.com> writes:

>>>>> Alexandre Oliva <oliva@dcc.unicamp.br> writes:

    >> On Nov 2, 1998, Jason Merrill <jason@cygnus.com> wrote:
    >>>>>>>> Alexandre Oliva <oliva@dcc.unicamp.br> writes:
    >>>> Within the scope of S<T>, `a', `S::a' and `S<T>::a' are all
    >>>> the same thing

    >>> Nope.  S::a and S<T>::a are the same, but they are dependent,
    >>> and `a' is not.  g++ doesn't currently implement that
    >>> consistently.

    >> The point I was trying to make is that they *should* be the
    >> same thing.

    Jason> And my point is that the standard says they aren't.

Concretely, consider this:

  const int a = 7;

  template <class T>
  struct S : public T {
    int j [S<T>::a];
    int k [a];
  };

  struct U {
    static const int a = 3; 
  };

Now, in `S<U>', `S<U>::a' is 3 while `a' is 7.

-- 
Mark Mitchell 			mark@markmitchell.com
Mark Mitchell Consulting	http://www.markmitchell.com



More information about the Libstdc++ mailing list