Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rule 14–6–1 and injected-class-names
#1
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:
Code:
typename B::TYPE t2 = 0; // Compliant - explicit use base TYPE
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:
Code:
typename ::B::TYPE t2 = 0; // Compliant - explicit use of B and of TYPE.
...to f2().

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>
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)