Static data members in template declarations

Mark Mitchell mark@markmitchell.com
Mon Nov 9 17:28:00 GMT 1998


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

    Jason> Let's make it work.

Simple enough to say. :-)  (By the way, since the example below is
mine, I would have appreciated being in the loop on whatever
discussion was taking place about it.)

In any case, we need to understand under exactly which circumstances
these things match.  John, do you have a proposal handy?  For example,
what about:

  template <class T>
  struct B {
    enum E { a = 1 
             /* So that John will be happy with the array. :-) */ 
	   }; 
  };

  template <class T>
  struct D : public B<T> {
    static T t[B<T>::a];
  };

  template <class T>
  T S<T>::t[S<T>::a];

In the same way as for my original example, you can reason that
`S<T>::a' must refer to the same thing as `B<T>::a', even though
`B<T>::a' is dependent, and not resolved in the first phase of lookup.
There is no `a' in `S<T>' proper, so if `S<T>::a' is going to make
sense at all, it must be because it is in fact `B<T>::a'.  Is the
compiler supposed to figure this out though?  What if the last line
says just plain `a', not `S<T>::a'?

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



More information about the Libstdc++ mailing list