03-07-2008, 04:56 PM
Hi all,
Rule 14–6–1 says:
"In a class template with a dependent base, any name
that may be found in that dependent base shall be
referred to using a qualified-id or this->"
But then the example code contains this line:
But I don't think that's correct, because although TYPE is qualified, B is not. I think this line should be moved into A::f1() and commented with "Non-compliant: B is unqualified". And add the line:
...to f2().
Here's an example where it makes a difference:
Rule 14–6–1 says:
"In a class template with a dependent base, any name
that may be found in that dependent base shall be
referred to using a qualified-id or this->"
But then the example code contains this line:
Code:
typename B::TYPE t2 = 0; // Compliant - explicit use base TYPE
Code:
typename ::B::TYPE t2 = 0; // Compliant - explicit use of B and of TYPE.
Here's an example where it makes a difference:
Code:
template
struct B {
static void j();
};
namespace N {
template
struct B {
static void j();
};
}
template
struct A : public N::B {
static void f1 ( ) {
A::template B::j(); // compliant
A::B::j(); // compliant
}
static void f2 ( ) {
B::j(); // non-compliant
}
};
void h() {
A::f1(); // calls ::N::B::j() twice
A::f2(); // calls ::B::j() once
}
<r>James Widman<br/>
-- <br/>
Gimpel Software<br/>
<URL url="http://gimpel.com">http://gimpel.com</URL></r>
-- <br/>
Gimpel Software<br/>
<URL url="http://gimpel.com">http://gimpel.com</URL></r>