Namespaces
Variants

std::meta::members_of

From cppreference.com
< cpp | meta
 
 
 
Reflection library
 
Reflection types and queries
Reflection queries
Reflection layout queries
Type properties
Type property queries
 
Defined in header <meta>
consteval std::vector<std::meta::info>
    members_of( std::meta::info r, std::meta::access_context ctx );
(since C++26)

Returns a std::vector containing the reflections of the members of the class type or namespace represented by r, filtered by the access context ctx.

Each reflection m in the result represents an accessible member that has an eligible declaration and is representable (see below). Accessibility is determined as if by std::meta::is_accessible(m, ctx).

Let Q be the class type or namespace represented by r.

A declaration is eligible if it meets all the following requirements:

  • It is in the scope of Q. (A block-scope function declaration is not eligible, for example.)
  • It is not a friend declaration.
  • It is not the declaration of a closure type.
  • It is not the declaration of a (partial or full) template specialization.
  • If Q is a class type that is not a closure type, the declaration introduces a direct member of Q that is not a variant member of a nested anonymous union of Q.
  • If Q is a closure type, the declaration introduces a function call operator or function call operator template.

It is implementation-defined whether declarations of other members of a closure type Q are eligible.

Only declarations before the members_of call are considered.

A member is representable if it is one of the following:

  • a class or enumeration type
  • a type alias
  • a class template, function template, variable template, alias template, or concept
  • a variable or reference whose type does not contain an undeduced placeholder type
  • a function F for which:
  • the type of F does not contain an undeduced placeholder type;
  • the constraints (if any) of F are satisfied; and
  • if F is a prospective destructor, it is the selected destructor
  • a data member
  • a namespace
  • a namespace alias

This function treats unnamed bit-fields declared in the scope of Q as data members with the same access.

Reflections of class members and unnamed bit-fields appear in the order in which they are declared. Implicitly-declared special members appear after any user-defined members.

Parameters

r - a reflection of complete class type or namespace
ctx - an access context

Return value

A std::vector of reflection values that represents class members or namespace members.

Exceptions

Throws std::meta::exception unless std::meta::dealias(r) represents either a class type complete from some point in the evaluation context, or a namespace.

Example

See also

(C++26)
obtains the accessible direct bases of the reflected class
(function) [edit]
Morty Proxy This is a proxified and sanitized view of the page, visit original site.