Title
Misleading comment on example in templates chapter
Status
cd1
Section
13.8 [temp.res]
Submitter
Jason Shirk

Created on 2002-03-18.00:00:00 last changed 189 months ago

Messages

Date: 2003-04-15.00:00:00

[Voted into WP at April 2003 meeting.]

Date: 2002-10-15.00:00:00

Proposed resolution (October 2002):

In 13.8 [temp.res] paragraph 4, replace the example with:

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 -- T::X refers to B::X.
  f(a);  // error: T::X refers to the data member A::X not
         // the struct A::X.
}
Date: 2004-09-10.00:00:00

The following example from 13.8 [temp.res] paragraph 4:

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
}

is not ill-formed. The intent of the example is obvious, but some mention should be made that it is only ill-formed when T=A. For other T's, it could be well formed.

History
Date User Action Args
2008-10-05 00:00:00adminsetstatus: wp -> cd1
2003-04-25 00:00:00adminsetmessages: + msg874
2003-04-25 00:00:00adminsetstatus: ready -> wp
2002-11-08 00:00:00adminsetmessages: + msg730
2002-11-08 00:00:00adminsetstatus: open -> ready
2002-03-18 00:00:00admincreate