Files
cppdraft_translate/cppdraft/basic/scope/param.md
2025-10-25 03:02:53 +03:00

51 lines
3.6 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[basic.scope.param]
# 6 Basics [[basic]](./#basic)
## 6.4 Scope [[basic.scope]](basic.scope#param)
### 6.4.4 Function parameter scope [basic.scope.param]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/basic.tex#L1456)
A [*parameter-declaration-clause*](dcl.fct#nt:parameter-declaration-clause "9.3.4.6Functions[dcl.fct]") P introduces
a [*function parameter scope*](#def:scope,function_parameter "6.4.4Function parameter scope[basic.scope.param]") that includes P[.](#1.sentence-1)
[*Note [1](#note-1)*:
A function parameter cannot be used for its value
within the [*parameter-declaration-clause*](dcl.fct#nt:parameter-declaration-clause "9.3.4.6Functions[dcl.fct]") ([[dcl.fct.default]](dcl.fct.default "9.3.4.7Default arguments"))[.](#1.sentence-2)
— *end note*]
- [(1.1)](#1.1)
If P is associated with a [*declarator*](dcl.decl.general#nt:declarator "9.3.1General[dcl.decl.general]") and
is preceded by a (possibly-parenthesized) [*noptr-declarator*](dcl.decl.general#nt:noptr-declarator "9.3.1General[dcl.decl.general]") of
the form[*declarator-id*](dcl.decl.general#nt:declarator-id "9.3.1General[dcl.decl.general]") [*attribute-specifier-seq*](dcl.attr.grammar#nt:attribute-specifier-seq "9.13.1Attribute syntax and semantics[dcl.attr.grammar]")opt,
its scope extends to the end of the nearest enclosing[*init-declarator*](dcl.decl.general#nt:init-declarator "9.3.1General[dcl.decl.general]"),[*member-declarator*](class.mem.general#nt:member-declarator "11.4.1General[class.mem.general]"),[*declarator*](dcl.decl.general#nt:declarator "9.3.1General[dcl.decl.general]") of a [*parameter-declaration*](dcl.fct#nt:parameter-declaration "9.3.4.6Functions[dcl.fct]") or
a [*nodeclspec-function-declaration*](dcl.pre#nt:nodeclspec-function-declaration "9.1Preamble[dcl.pre]"), or[*function-definition*](dcl.fct.def.general#nt:function-definition "9.6.1General[dcl.fct.def.general]"),
but does not include the locus of the associated [*declarator*](dcl.decl.general#nt:declarator "9.3.1General[dcl.decl.general]")[.](#1.1.sentence-1)
[*Note [2](#note-2)*:
In this case, P declares the parameters of a function
(or a function or template parameter declared with function type)[.](#1.1.sentence-2)
A member function's parameter scope is nested within its class's scope[.](#1.1.sentence-3)
— *end note*]
- [(1.2)](#1.2)
If P is associated with a [*lambda-declarator*](expr.prim.lambda.general#nt:lambda-declarator "7.5.6.1General[expr.prim.lambda.general]"),
its scope extends to the end of the [*compound-statement*](stmt.block#nt:compound-statement "8.4Compound statement or block[stmt.block]") in the [*lambda-expression*](expr.prim.lambda.general#nt:lambda-expression "7.5.6.1General[expr.prim.lambda.general]")[.](#1.2.sentence-1)
- [(1.3)](#1.3)
If P is associated with a [*requirement-parameter-list*](expr.prim.req.general#nt:requirement-parameter-list "7.5.8.1General[expr.prim.req.general]"),
its scope extends to the end of the [*requirement-body*](expr.prim.req.general#nt:requirement-body "7.5.8.1General[expr.prim.req.general]") of the [*requires-expression*](expr.prim.req.general#nt:requires-expression "7.5.8.1General[expr.prim.req.general]")[.](#1.3.sentence-1)
- [(1.4)](#1.4)
If P is associated with a [*deduction-guide*](temp.deduct.guide#nt:deduction-guide "13.7.2.3Deduction guides[temp.deduct.guide]"),
its scope extends to the end of the [*deduction-guide*](temp.deduct.guide#nt:deduction-guide "13.7.2.3Deduction guides[temp.deduct.guide]")[.](#1.4.sentence-1)