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.


[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index] [Subject Index] [Author Index] [Thread Index]

Re: Static data members in template declarations



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

    Alexandre> On Nov 2, 1998, Mark Mitchell <mark@markmitchell.com>
    Alexandre> wrote:

    >> 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.

    Alexandre> But this is completely different from the previous
    Alexandre> example.  In that example, a was declared within the
    Alexandre> template class, so it couldn't possibly be bound to
    Alexandre> names outside the template class body.

But this is my point; you are asking that the compiler figure this out
while parsing the definition of the array.  So, you would like the
compiler to peek *inside* the type-dependent expression `S<T>::a' and
figure out whether or not there is an `a' in `S<T>', even though that
type is type-dependent.  This seems unlikely.

Martin suggests that we should delay checking whether or not the array
is the same array until instantiation time.  This is a reasonable and
consistent point of view, but very hard to implement.  For example,
would you extend this to member functions:

  template <class T>
  struct S { 
    void f(T*);
  };

  template <class T>
  void S<T>::f(typename T::X) {}

Should we wait to figure out whether this the same `f' until we
instantiate S, and determine whether or not T::X is the same as T*?
This seems unreasonable to me.
  
-- 
Mark Mitchell 			mark@markmitchell.com
Mark Mitchell Consulting	http://www.markmitchell.com