This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of New status.

4591. std::meta::current_function should probably work in a local class

Section: 21.4.8 [meta.reflection.scope] Status: New Submitter: S. B. Tam Opened: 2026-05-31 Last modified: 2026-06-13

Priority: Not Prioritized

View all issues with New 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.

This might be an oversight, as neither P3795 (which introduced this function) nor https://wg21.link/P3795/github has any discussion concerning local classes.

Example:

#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;
}

Proposed resolution: