cplusplus / cplusplus/draft

[dcl.meaning.general] p3.3 The lookup for the declarator-id that is an identifier in the explicit instantiation or specialization for function template

Open
#5,496 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TeX
Stars
221
Forks
813
Avg merge
16h 4m
Merged PRs (30d)
36

Description

If the declarator declares an explicit instantiation or a partial or explicit specialization, the declarator does not bind a name. If it declares a class member, the terminal name of the declarator-id is not looked up; otherwise, only those lookup results that are nominable in S are considered when identifying any function template specialization being declared ([temp.deduct.decl]).

Consider this example:

void fun(int*, void*);  // #1

template<class T, class U>
void fun(T*, U*);   // #2

template<>
void fun(int*, void*);  // #3

We do not restrict more requirements on the name lookup for fun. The result should consist of #1 and #2. [temp.deduct.decl] p1 says

In a declaration whose declarator-id refers to a specialization of a function template, template argument deduction is performed to identify the specialization to which the declaration refers.

It is not clear whether the declarator-id that is an identifier refers to a specialization of a function template or not. We just say

A template specialization can be referred to by a template-id

in [temp.names] p1. The identifier refers to a specialization only if the deduction succeeds, I think. [temp.deduct.decl] p1 also says

In all these cases, P is the type of the function template being considered as a potential match...

This implies that only function templates are considered when identifying any function template specialization.

[dcl.meaning.general] p3.3 might be changed to

otherwise, only those lookup results that are function templates and are nominable in S are considered when identifying any function template specialization being declared ([temp.deduct.decl]).

change [temp.deduct.decl] p1 to

In explicit instantiations, explicit specializations, and certain friend declarations, template argument deduction is performed to identify the template of which the specialization is being declared/instantiated by the declaration.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by comparing the wording in [dcl.meaning.general] p3.3, [temp.deduct.decl] p1, and [temp.names] p1 against the provided function-template example. The work is done when the standard clearly specifies which lookup results are considered and how the declarator-id refers to the template being declared or instantiated.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
documentation
Issue type
Documentation
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.