Is it a defect in the standard about dependent name resolution for template

jack X

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:

  1. Declarations that are visible at the point of definition of the template.
  2. 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.

Raffi

To complete language-lawyer comments, in §"Unknown specializations" of this page

Within a template definition, certain names are deduced to belong to an unknown specialization, in particular,

  • a qualified name, if any name that appears to the left of :: is a dependent type that is not a member of the current instantiation
  • ...

In your struct TMP,

  • the type T is indeed a dependent type
  • the expression typename T::type is a qualified name and the left if :: is a dependent type
  • that expression becomes an unknown specialization

Then it is said:

Members of unknown specialization are always dependent, and are looked up and bound at the point of instantiation as all dependent names

which allows the lookup of TMP<Test>::type at the point of instanciation.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Function template overload resolution, dependent and non-dependent parameters

Why is template function of data member a dependent name only when qualifying with "this"?

Does the C standard have a website for defect reports?

How to create dependent tinymce textarea according to the selection of email template name?

The template disambiguator for dependent names

Why is initialization of a constant dependent type in a template parameter list disallowed by the standard?

When does overload resolution of non-dependent name take place, in definition context or point of instantiation?

Template specialization with dependent values

Template dependent typename

Why dependent template name accepted without keyword?

Why does the C++ standard specify that unqualified names in a template are non-dependent?

Type dependent template name

Implicit resolution of dependent types in Scala

Is not matching a template<typename...> to template<typename> a defect?

Template dependent name resolution should not find declarations with no linkage?

Template dependent false

Dependent name lookup in base class template

Can I get a const dependent name from a const type template argument when instantiating a template?

refer to a non-dependent name without specifying template parameter

Name lookup on template base classes in non-dependent name scenarios

Confused about C++ nested dependent type name

Template disambiguator for dependent names

Is this really a dependent template name?

Is it a defect when the base class is a dependent type

mv complains about standard input in a pipeline that filters file name with grep

C++ name resolution for member functions in template class

What does the standard say about char arrays as template arguments?

Template resolution with template template parameter

Remove Trace Name in Plotly Hover while Keeping Standard Template

TOP Ranking

HotTag

Archive