Unless otherwise specified,
a qualified name undergoes qualified name lookup in its lookup context
from the point where it appears
unless the lookup context either
is dependent and is not the current instantiation (
[temp.dep.type]) or
is not a class or class template
. [
Note 2:
During lookup for a template specialization, no names are dependent
. —
end note]
[
Example 3:
int f();
struct A {
int B, C;
template<int> using D = void;
using T = void;
void f();
};
using B = A;
template<int> using C = A;
template<int> using D = A;
template<int> using X = A;
template<class T>
void g(T *p) {
p->X<0>::f();
p->template X<0>::f();
p->B::f();
p->template C<0>::f();
p->template D<0>::f();
p->T::f();
}
template void g(A*);
—
end example]
If a qualified name
Q follows a
~:
If
Q is a member-qualified name,
it undergoes unqualified lookup as well as qualified lookup
. Otherwise, if the terminal name of
N is a member-qualified name
M,
Q is looked up as if
~Q appeared in place of
M (as above)
.Otherwise,
Q undergoes unqualified lookup
.Each lookup for
Q considers only
types (if
Q is not followed by a
<) and
templates whose specializations are types
. If it finds nothing or is ambiguous, it is discarded
.The
type-name that is or contains
Q
shall refer to its (original) lookup context (ignoring cv-qualification) under
the interpretation established by at least one (successful) lookup performed
. [
Example 4:
struct C {
typedef int I;
};
typedef int I1, I2;
extern int* p;
extern int* q;
void f() {
p->C::I::~I();
q->I1::~I2();
}
struct A {
~A();
};
typedef A AB;
int main() {
AB* p;
p->AB::~AB();
}
—
end example]