Topic: class template base class dependency on template parameter
Author: John Lilley <jlilley@empathy.com>
Date: 1997/01/20 Raw View
Hello,
With respect to the dec96 draft: I've recently submitted a comment
regarding dependency on a template parameter when the template parameter
is involved in the base class. 14.6.2/5 clarifies dependency on a
template parameter when the template parameter is used as a base class,
but I think there are a couple of cases that require clarification.
Note that drafts prior to dec96 may be significantly different.
First, consider a template parameter as an *indirect* base class:
struct A {
struct B { /*...*/ };
int a;
int Y;
};
template <class T> struct AA : public T {};
int a;
template <class T> struct Y : public AA<T> {
struct B { /*...*/ };
B b; // B defined in Y ??
void f(int i) { a = i; } // ::a ??
Y* p; // Y<T> ??
}
Y<A> ya;
In short, can the conclusions of 14.6.2/5 still be drawn when the
template parameter is an indirect base class?
The second example is a bit more complex and has to do with template
partial specializations:
template <class T> struct A {};
template <> struct A<int> {
struct B { /*...*/ };
int a;
int Y;
};
int a;
template <class T> struct Y : public A<T> {
struct B { /*...*/ };
B b; // B defined in Y ??
void f(int i) { a = i; } // ::a ??
Y* p; // Y<T> ??
}
Y<int> ya;
In short, can the conclusions of 14.6.2/5 still be drawn when the
template parameter is involved in the selection of a base class which is
a template specialization (or partial specialization for that matter)?
The case involving a template specialization as a base class is more
difficult, because on one hand you want declarations of a "normal" base
class to override declarations where appropriate, but you don't want
members of indeterminate base classes to override.
I suggest that the language of 14.6.2/5 be amended to read something
like:
"If a base class of a class template is one of:
-- a template-argument.
-- a template-id whose argument list contains a
template-argument, where the correct specialization
of template-id cannot be chosen until the
template-argument is known.
-- a template-id whose argument list contains a
template-argument, and which has a base class
falling into one of the two cases above.
then a member of that base class cannot hide a name declared
with a template, or a name from the template's enclosing scopes."
Any comments on my comment?
john lilley
[ comp.std.c++ is moderated. To submit articles: try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]