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.

4422. meta::access_context should be a consteval-only type

Section: 21.4.8 [meta.reflection.access.context] Status: New Submitter: Jakub Jelinek Opened: 2025-10-20 Last modified: 2025-10-23

Priority: 2

View all issues with New status.

Discussion:

The meta::access_context type is expected to contain some meta::info objects, which would make it a consteval-only type. But we don't actually specify any members, so nothing in the current specification says you can't persist one until runtime.

[2025-10-23; Reflector poll. Adjust proposed wording.]

Set priority to 2 after reflector poll.

Reflector discussion requested that 'non-aggregate' and 'consteval-only' both be put in paragraph 3, adjacent to 'structural'. Also added a drive-by editorial change to paragraph 1.

Proposed resolution:

This wording is relative to N5014.

  1. Modify 21.4.8 [meta.reflection.access.context] as indicated:

    -1- The class access_context class is a non-aggregate type that represents a namespace, class, or function from which queries pertaining to access rules may be performed, as well as the designating class (11.8.3 [class.access.base]), if any.

    -2- An access_context has an associated scope and designating class.

    namespace std::meta {
      struct access_context {
        access_context() = delete;
    
        consteval info scope() const;
        consteval info designating_class() const;
    
        static consteval access_context current() noexcept;
        static consteval access_context unprivileged() noexcept;
        static consteval access_context unchecked() noexcept;
        consteval access_context via(info cls) const;
      };
    }

    -3- access_context is a structural, consteval-only, non-aggregate type. Two values ac1 and ac2 of type access_context are template-argument-equivalent (13.6 [temp.type]) if ac1.scope() and ac2.scope() are template-argument-equivalent and ac1.designating_class() and ac2.designating_class() are template-argument-equivalent.