Date: Sun, 26 Jan 2025 14:31:22 +0100
On 26/01/2025 14.21, Russell Shaw via Std-Discussion wrote:
> Hi,
>
> In [expr.const] p.154:
>
> ---------------------------------------------------------------
> An immediate function is a function or constructor that is
> — declared with the consteval specifier, or
> — an immediate-escalating function F whose function body contains an
> immediate-escalating expression E such that E ’s innermost enclosing non-block
> scope is F ’s function parameter scope.
>
> example 9
>
> consteval int id(int i) { return i; }
>
> constexpr char id(char c) { return c; }
>
> template<class T>
> constexpr int f(T t) {
> return t + id(t);
> }
>
> auto a = &f<char>; // OK, f<char> is not an immediate function
>
> auto b = &f<int>; // error: f<int> is an immediate function
> ---------------------------------------------------------------
>
> The immediate-escalating function 'f' function parameter scope does not contain
> an immediate-escalating expression.
"f" is not a function, but a function template.
> The 'f' instantiation declarations are: 'int
> f(int t)' and 'int f(char t)'.
Yes, so what?
> What is wrong ?
Nothing is wrong (given the information you provided).
What is your question?
Jens
> Hi,
>
> In [expr.const] p.154:
>
> ---------------------------------------------------------------
> An immediate function is a function or constructor that is
> — declared with the consteval specifier, or
> — an immediate-escalating function F whose function body contains an
> immediate-escalating expression E such that E ’s innermost enclosing non-block
> scope is F ’s function parameter scope.
>
> example 9
>
> consteval int id(int i) { return i; }
>
> constexpr char id(char c) { return c; }
>
> template<class T>
> constexpr int f(T t) {
> return t + id(t);
> }
>
> auto a = &f<char>; // OK, f<char> is not an immediate function
>
> auto b = &f<int>; // error: f<int> is an immediate function
> ---------------------------------------------------------------
>
> The immediate-escalating function 'f' function parameter scope does not contain
> an immediate-escalating expression.
"f" is not a function, but a function template.
> The 'f' instantiation declarations are: 'int
> f(int t)' and 'int f(char t)'.
Yes, so what?
> What is wrong ?
Nothing is wrong (given the information you provided).
What is your question?
Jens
Received on 2025-01-26 13:31:33