About how lookup the dependent name for template, The standard only gives a little sentence like this, there's no more:
In resolving dependent names, names from the following sources are considered:
- Declarations that are visible at the point of definition of the template.
- Declarations from namespaces associated with the types of the function arguments both from the instantiation context ([temp.point]) and from the definition context.
Consider the below code
struct Test{
using type = int;
};
// #1
template<typename T>
struct TMP{
using type = typename T::type;
};
int main(){
TMP<Test>::type v = 0;
}
For this code, the name type
indeed a dependent name because T is a template parameter and here is not a function call, So, the only relevant bullet point is Number 1. It only says the dependent name shall be visible before the template definition, It means in my code, the declaration shall be visible at #1
. In actually, typename T::type
is a qualified-id, hence qualified name lookup rules apply to it and because T
is a template parameter, So the lookup action shall be occurred after given a template argument, namely, during the instantiation of a specialization for such a template. But the quote I cited does not say anything about this. So, I wonder Is it a defect in the standard? If I miss anything that interpret this in the standard, please cite them for this question.