Title
Confusing example on lookup with typename
Status
dup
Section
13.8 [temp.res]
Submitter
Manish Pagey

Created on 2002-08-23.00:00:00 last changed 261 months ago

Messages

Date: 2002-10-15.00:00:00

Notes from October 2002 meeting:

This is a duplicate of Core Issue 345.

Date: 2002-08-23.00:00:00

Section 13.8 [temp.res] paragraph 4 uses the following example to show that qualified name lookup described in Section 6.5.5 [basic.lookup.qual] applies even in the presence of "typename":

  struct A {
    struct X { } ;
    int X ;
  } ;
  template<class T> void f(T t) {
    typename T::X x ; // ill-formed: finds the data member X
                      // not the member type X
  }

This example is confusing because the definition of the template function itself is not ill formed unless it is instantiated with "A" as the template parameter. In other words, the example should be modified to something like:

  struct A {
    struct X { } ;
    int X ;
  } ;
  struct B {
    struct X { } ;
  } ;
  template<class T> void f(T t) {
    typename T::X x ;
  }
  void foo() {
    A a ;
    B b ;
    f(b) ; // OK -- finds member type B::X.
    f(a) ; // ill-formed: finds the data member A::X not
           // the member type A::X.
  }
History
Date User Action Args
2002-11-08 00:00:00adminsetmessages: + msg790
2002-11-08 00:00:00adminsetstatus: open -> dup
2002-08-23 00:00:00admincreate