This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of Ready status.
std::meta::current_function should probably work in a local classSection: 21.4.8 [meta.reflection.scope] Status: Ready Submitter: S. B. Tam Opened: 2026-05-31 Last modified: 2026-09-11
Priority: 2
View all issues with Ready status.
Discussion:
std::meta::current_function is specified to throw if CURRENT-SCOPE(P)
does not represent a function. It is implied that current_function throws if the call is
directly contained in a local class, in which case it's actually in a function body, but indirectly.
#include <meta>
template<auto V> struct A { static constexpr auto value = V; };
consteval std::meta::info test() {
struct Local { using T = A<std::meta::current_function()>; }; // valid or not?
return Local::T::value;
}
[2026-06-16, Barry Revzin provides wording]
This wording is relative to N5046.
Modify 21.4.8 [meta.reflection.scope] as indicated:
consteval info current_function();-6- An invocation of
-7- Letcurrent_functionthat appears at a program pointPis value-dependent (13.8.3.4 [temp.dep.constexpr]) ifeval-point(P)is enclosed by a scope corresponding to a templated entity.SbeCURRENT-SCOPE(P), wherePis the point at which the invocation ofcurrent_functionlexically appears. -8- Returns:SifSrepresents a function. Otherwise,parent_of(S). -9- Throws:meta::exceptionunlessSrepresents a function.
[2026-06-16; Ville Voutilainen provides improved wording]
[2026-08-27; Reflector poll.]
Set priority to 2 after reflector poll.
"we should say this in words, similar to current_namespace."
This wording is relative to N5046.
Modify 21.4.8 [meta.reflection.scope] as indicated:
consteval info current_function();-6- An invocation of
-7- Letcurrent_functionthat appears at a program pointPis value-dependent (13.8.3.4 [temp.dep.constexpr]) ifeval-point(P)is enclosed by a scope corresponding to a templated entity.SbeCURRENT-SCOPE(P), wherePis the point at which the invocation ofcurrent_functionlexically appears. -8- Returns:SifSrepresents a function. Otherwise, a reflection representing the nearest enclosing function of the entity represented byS. -9- Throws:meta::exceptionunlessan enclosing function is found.Srepresents a function
[2026-09-11; Tim provides new wording]
The invented lambdas from consteval-block-declarations need to be ignored.
[2026-09-11; LWG telecon. Status changed: New → Ready.]
Proposed resolution:
This wording is relative to N5046.
Modify 21.4.8 [meta.reflection.scope] as indicated:
consteval info current_function();-6- An invocation of
-7- Letcurrent_functionthat appears at a program pointPis value-dependent (13.8.3.4 [temp.dep.constexpr]) ifeval-point(P)is enclosed by a scope corresponding to a templated entity.SbeCURRENT-SCOPE(P), wherePis the point at which the invocation ofcurrent_functionlexically appears. -8- Returns:SifSrepresents a function. Otherwise, a reflection representing the nearest enclosing function of the entity represented byS, ignoring any function call operators of closure types introduced by consteval-block-declarations (9.1 [dcl.pre]). -9- Throws:meta::exceptionunlessifSdoes not representrepresentsa function and an enclosing function is not found.