Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
xmh0511 opened this issue Jun 28, 2022 · 0 comments
Open

Comments

@xmh0511
Copy link
Contributor

xmh0511 commented Jun 28, 2022

[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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant