Date: Mon, 27 Jan 2025 00:21:13 +1100
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. The 'f' instantiation declarations are: 'int
f(int t)' and 'int f(char t)'. What is wrong ?
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. The 'f' instantiation declarations are: 'int
f(int t)' and 'int f(char t)'. What is wrong ?
Received on 2025-01-26 13:21:20