cplusplus / cplusplus/draft

[temp.inst] p12 "In a function template specialization" is not defined

Open
#5,542 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

[temp.inst] p12 says

If a function template f is called in a way that requires a default argument to be used, the dependent names are looked up, the semantics constraints are checked, and the instantiation of any template used in the default argument is done as if the default argument had been an initializer used in a function template specialization with the same scope, the same template parameters and the same access as that of the function template f used at that point, except that the scope in which a closure type is declared ([expr.prim.lambda.closure]) – and therefore its associated namespaces – remain as determined from the context of the definition for the default argument.

What does "in a function template specialization" mean? Does it mean in the fiction declaration of the specialization or in the fiction body of the specialization? CWG1664 implies the meaning should be latter

A possibility, then, is that the closure type for a lambda expression in a default argument for a template function (or, presumably, a member function of a class template) is to be considered as having been declared in some block scope in the body of the fictional function template specialization.

The improvement might be

If a specialization of a function template f is called in a way that requires a default argument to be used, the dependent names are looked up, the semantics constraints are checked, and the instantiation of any template used in the default argument is done as if the default argument had been an initializer of an invented variable that inhabits the block scope associated with that of the body of f that is introduced by the function template specialization([basic.scope.scope] p7), where the function template specialization has the same scope, the same template parameters and the same access as that of the function template f used at that point. except that the scope in which a closure type is declared ([expr.prim.lambda.closure]) – and therefore its associated namespaces – remain as determined from the context of the definition for the default argument.

[basic.scope.scope] p7 says

When instantiating a templated entity ([temp.pre]), any scope S introduced by any part of the template definition is considered to be introduced by the instantiated entity and to contain the instantiations of any declarations that inhabit S.

The part of the except... is not necessary, since the innermost enclosing namespace of a local class is that of the function in which the local class is declared.

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 reading [temp.inst] p12 alongside CWG1664 and [basic.scope.scope] p7. Determine whether the phrase “in a function template specialization” identifies a declaration or body scope, and assess the proposed replacement wording. Done means the ambiguity and exception are resolved in agreed standard wording.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.