C++ Logo

std-discussion

Advanced search

Re: Immediate functions

From: Jens Maurer <jens.maurer_at_[hidden]>
Date: Sun, 26 Jan 2025 14:50:53 +0100
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.

Jens

Received on 2025-01-26 13:51:09