Date: Mon, 27 Jan 2025 01:11:48 +1100
On 27/1/25 00:50, Jens Maurer wrote:
>
> On 26/01/2025 14.41, Russell Shaw via Std-Discussion wrote:
>> The example says:
>> auto b = &f<int>; // error: f<int> is an immediate function
>>
>> But the instantiated function is:
>>
>> constexpr int f(int t) {
>> return t + id(t);
>> }
>>
>> The function parameter scope is '(int t)' (or does it encompass the body too ?)
>
> It does encompass the function body, otherwise "t" wouldn't be
> visible in the body. See [basic.scope.param] p1.
>
>> Where is the immediate-escalating expression E such that E ’s innermost
>> enclosing non-block scope is F ’s function parameter scope ?
>
> "id(t)" is the expression.
Ok.
[basic.scope.param] adds no useful information.
[basic.scope.block] says that the function parameter scope is the parent scope
of the function body (if my understanding that the function body is classed as a
compound statement and thus a block scope is correct ?)
So i was thinking 'function parameter scope' was strictly the part not
overlapped by the body scope.
>
> On 26/01/2025 14.41, Russell Shaw via Std-Discussion wrote:
>> The example says:
>> auto b = &f<int>; // error: f<int> is an immediate function
>>
>> But the instantiated function is:
>>
>> constexpr int f(int t) {
>> return t + id(t);
>> }
>>
>> The function parameter scope is '(int t)' (or does it encompass the body too ?)
>
> It does encompass the function body, otherwise "t" wouldn't be
> visible in the body. See [basic.scope.param] p1.
>
>> Where is the immediate-escalating expression E such that E ’s innermost
>> enclosing non-block scope is F ’s function parameter scope ?
>
> "id(t)" is the expression.
Ok.
[basic.scope.param] adds no useful information.
[basic.scope.block] says that the function parameter scope is the parent scope
of the function body (if my understanding that the function body is classed as a
compound statement and thus a block scope is correct ?)
So i was thinking 'function parameter scope' was strictly the part not
overlapped by the body scope.
Received on 2025-01-26 14:11:54