[C++] Unreviewed patches

Giovanni Bajo giovannibajo@libero.it
Sat Jan 10 00:55:00 GMT 2004


Gabriel Dos Reis wrote:

>>> ------------------------------------
>>> struct B {
>>>   typedef int K;
>>> };
>>> template <class T> struct D : T {
>>>   typedef typename D::K K2;
>>> };
>>> ------------------------------------
>> I do not think this is valid. IIU 224 correctly, the
>> nested-name-specifier (which is D) is not dependent, therefore we do
>> the lookup and definition
>
> I disagree.  The 'D' in "D::K" is the injected class-name, and
> is therefore equivalent to D<T>, and is dependent.

D<T>::K or D::K are non dependent names, because of the resolution of DR224.
The new 14.6.2.1 introduces the term "current instantiation", which is defined
as "the injected class name" or "name of the class template followed by the
template argument list of the primary template (as described below) enclosed in
<>", which in our case is exactly D and D<T>. Then, it introduces a "member of
the current instantiation", which is (among the others) a qualified-id in which
the nested-name-specifier refers to the current instatiation. Thus, D::K or
D<T>::K both refer to the current instantiation. Then, the definition of "type
dependent" does not include "members of the current instiantiation"
specifically to rule out these cases.

>> time (looking in D and any non-dependent bases), and in this case we
>> find nothing, so it is an error.
>
> No, you cannot look into D, because it is dependent.

DR224 is about changing the definition of dependent from "syntatically
dependent" to "semantically dependent".

Giovanni Bajo




More information about the Gcc-patches mailing list