21 Metaprogramming library [meta]

21.4 Reflection [meta.reflection]

21.4.1 Header <meta> synopsis [meta.syn]

#include <initializer_list> // see [initializer.list.syn] namespace std { // [meta.string.literal], checking string literals consteval bool is_string_literal(const char* p); consteval bool is_string_literal(const wchar_t* p); consteval bool is_string_literal(const char8_t* p); consteval bool is_string_literal(const char16_t* p); consteval bool is_string_literal(const char32_t* p); // [meta.define.static], promoting to static storage strings template<ranges::input_range R> consteval const ranges::range_value_t<R>* define_static_string(R&& r); template<ranges::input_range R> consteval span<const ranges::range_value_t<R>> define_static_array(R&& r); template<class T> consteval const remove_cvref_t<T>* define_static_object(T&& r); } namespace std::meta { using info = decltype(^^::); // [meta.reflection.operators], operator representations enum class operators { see below; }; using enum operators; consteval operators operator_of(info r); consteval string_view symbol_of(operators op); consteval u8string_view u8symbol_of(operators op); // [meta.reflection.names], reflection names and locations consteval bool has_identifier(info r); consteval string_view identifier_of(info r); consteval u8string_view u8identifier_of(info r); consteval string_view display_string_of(info r); consteval u8string_view u8display_string_of(info r); consteval source_location source_location_of(info r); // [meta.reflection.queries], reflection queries consteval info type_of(info r); consteval info object_of(info r); consteval info constant_of(info r); consteval bool is_public(info r); consteval bool is_protected(info r); consteval bool is_private(info r); consteval bool is_virtual(info r); consteval bool is_pure_virtual(info r); consteval bool is_override(info r); consteval bool is_final(info r); consteval bool is_deleted(info r); consteval bool is_defaulted(info r); consteval bool is_user_provided(info r); consteval bool is_user_declared(info r); consteval bool is_explicit(info r); consteval bool is_noexcept(info r); consteval bool is_bit_field(info r); consteval bool is_enumerator(info r); consteval bool is_annotation(info r); consteval bool is_const(info r); consteval bool is_volatile(info r); consteval bool is_mutable_member(info r); consteval bool is_lvalue_reference_qualified(info r); consteval bool is_rvalue_reference_qualified(info r); consteval bool has_static_storage_duration(info r); consteval bool has_thread_storage_duration(info r); consteval bool has_automatic_storage_duration(info r); consteval bool has_internal_linkage(info r); consteval bool has_module_linkage(info r); consteval bool has_external_linkage(info r); consteval bool has_c_language_linkage(info r); consteval bool has_linkage(info r); consteval bool is_complete_type(info r); consteval bool is_enumerable_type(info r); consteval bool is_variable(info r); consteval bool is_type(info r); consteval bool is_namespace(info r); consteval bool is_type_alias(info r); consteval bool is_namespace_alias(info r); consteval bool is_function(info r); consteval bool is_conversion_function(info r); consteval bool is_operator_function(info r); consteval bool is_literal_operator(info r); consteval bool is_special_member_function(info r); consteval bool is_constructor(info r); consteval bool is_default_constructor(info r); consteval bool is_copy_constructor(info r); consteval bool is_move_constructor(info r); consteval bool is_assignment(info r); consteval bool is_copy_assignment(info r); consteval bool is_move_assignment(info r); consteval bool is_destructor(info r); consteval bool is_function_parameter(info r); consteval bool is_explicit_object_parameter(info r); consteval bool has_default_argument(info r); consteval bool has_ellipsis_parameter(info r); consteval bool is_template(info r); consteval bool is_function_template(info r); consteval bool is_variable_template(info r); consteval bool is_class_template(info r); consteval bool is_alias_template(info r); consteval bool is_conversion_function_template(info r); consteval bool is_operator_function_template(info r); consteval bool is_literal_operator_template(info r); consteval bool is_constructor_template(info r); consteval bool is_concept(info r); consteval bool is_value(info r); consteval bool is_object(info r); consteval bool is_structured_binding(info r); consteval bool is_class_member(info r); consteval bool is_namespace_member(info r); consteval bool is_nonstatic_data_member(info r); consteval bool is_static_member(info r); consteval bool is_base(info r); consteval bool has_default_member_initializer(info r); consteval bool has_parent(info r); consteval info parent_of(info r); consteval info dealias(info r); consteval bool has_template_arguments(info r); consteval info template_of(info r); consteval vector<info> template_arguments_of(info r); consteval vector<info> parameters_of(info r); consteval info variable_of(info r); consteval info return_type_of(info r); // [meta.reflection.access.context], access control context struct access_context; // [meta.reflection.access.queries], member accessessibility queries consteval bool is_accessible(info r, access_context ctx); consteval bool has_inaccessible_nonstatic_data_members(info r, access_context ctx); consteval bool has_inaccessible_bases(info r, access_context ctx); consteval bool has_inaccessible_subobjects(info r, access_context ctx); // [meta.reflection.member.queries], reflection member queries consteval vector<info> members_of(info r, access_context ctx); consteval vector<info> bases_of(info type, access_context ctx); consteval vector<info> static_data_members_of(info type, access_context ctx); consteval vector<info> nonstatic_data_members_of(info type, access_context ctx); consteval vector<info> subobjects_of(info type, access_context ctx); consteval vector<info> enumerators_of(info type_enum); // [meta.reflection.layout], reflection layout queries struct member_offset; consteval member_offset offset_of(info r); consteval size_t size_of(info r); consteval size_t alignment_of(info r); consteval size_t bit_size_of(info r); // [meta.reflection.extract], value extraction template<class T> consteval T extract(info); // [meta.reflection.substitute], reflection substitution template<class R> concept reflection_range = see below; template<reflection_range R = initializer_list<info>> consteval bool can_substitute(info templ, R&& arguments); template<reflection_range R = initializer_list<info>> consteval info substitute(info templ, R&& arguments); // [meta.reflection.result], expression result reflection template<class T> consteval info reflect_constant(const T& value); template<class T> consteval info reflect_object(T& object); template<class T> consteval info reflect_function(T& fn); // [meta.reflection.array], promoting to static storage arrays template<ranges::input_range R> consteval info reflect_constant_string(R&& r); template<ranges::input_range R> consteval info reflect_constant_array(R&& r); // [meta.reflection.define.aggregate], class definition generation struct data_member_options; consteval info data_member_spec(info type, data_member_options options); consteval bool is_data_member_spec(info r); template<reflection_range R = initializer_list<info>> consteval info define_aggregate(info type_class, R&&); // associated with [meta.unary.cat], primary type categories consteval bool is_void_type(info type); consteval bool is_null_pointer_type(info type); consteval bool is_integral_type(info type); consteval bool is_floating_point_type(info type); consteval bool is_array_type(info type); consteval bool is_pointer_type(info type); consteval bool is_lvalue_reference_type(info type); consteval bool is_rvalue_reference_type(info type); consteval bool is_member_object_pointer_type(info type); consteval bool is_member_function_pointer_type(info type); consteval bool is_enum_type(info type); consteval bool is_union_type(info type); consteval bool is_class_type(info type); consteval bool is_function_type(info type); consteval bool is_reflection_type(info type); // associated with [meta.unary.comp], composite type categories consteval bool is_reference_type(info type); consteval bool is_arithmetic_type(info type); consteval bool is_fundamental_type(info type); consteval bool is_object_type(info type); consteval bool is_scalar_type(info type); consteval bool is_compound_type(info type); consteval bool is_member_pointer_type(info type); // associated with [meta.unary.prop], type properties consteval bool is_const_type(info type); consteval bool is_volatile_type(info type); consteval bool is_trivially_copyable_type(info type); consteval bool is_trivially_relocatable_type(info type); consteval bool is_replaceable_type(info type); consteval bool is_standard_layout_type(info type); consteval bool is_empty_type(info type); consteval bool is_polymorphic_type(info type); consteval bool is_abstract_type(info type); consteval bool is_final_type(info type); consteval bool is_aggregate_type(info type); consteval bool is_consteval_only_type(info type); consteval bool is_signed_type(info type); consteval bool is_unsigned_type(info type); consteval bool is_bounded_array_type(info type); consteval bool is_unbounded_array_type(info type); consteval bool is_scoped_enum_type(info type); template<reflection_range R = initializer_list<info>> consteval bool is_constructible_type(info type, R&& type_args); consteval bool is_default_constructible_type(info type); consteval bool is_copy_constructible_type(info type); consteval bool is_move_constructible_type(info type); consteval bool is_assignable_type(info type_dst, info type_src); consteval bool is_copy_assignable_type(info type); consteval bool is_move_assignable_type(info type); consteval bool is_swappable_with_type(info type_dst, info type_src); consteval bool is_swappable_type(info type); consteval bool is_destructible_type(info type); template<reflection_range R = initializer_list<info>> consteval bool is_trivially_constructible_type(info type, R&& type_args); consteval bool is_trivially_default_constructible_type(info type); consteval bool is_trivially_copy_constructible_type(info type); consteval bool is_trivially_move_constructible_type(info type); consteval bool is_trivially_assignable_type(info type_dst, info type_src); consteval bool is_trivially_copy_assignable_type(info type); consteval bool is_trivially_move_assignable_type(info type); consteval bool is_trivially_destructible_type(info type); template<reflection_range R = initializer_list<info>> consteval bool is_nothrow_constructible_type(info type, R&& type_args); consteval bool is_nothrow_default_constructible_type(info type); consteval bool is_nothrow_copy_constructible_type(info type); consteval bool is_nothrow_move_constructible_type(info type); consteval bool is_nothrow_assignable_type(info type_dst, info type_src); consteval bool is_nothrow_copy_assignable_type(info type); consteval bool is_nothrow_move_assignable_type(info type); consteval bool is_nothrow_swappable_with_type(info type_dst, info type_src); consteval bool is_nothrow_swappable_type(info type); consteval bool is_nothrow_destructible_type(info type); consteval bool is_nothrow_relocatable_type(info type); consteval bool is_implicit_lifetime_type(info type); consteval bool has_virtual_destructor(info type); consteval bool has_unique_object_representations(info type); consteval bool reference_constructs_from_temporary(info type_dst, info type_src); consteval bool reference_converts_from_temporary(info type_dst, info type_src); // associated with [meta.unary.prop.query], type property queries consteval size_t rank(info type); consteval size_t extent(info type, unsigned i = 0); // associated with [meta.rel], type relations consteval bool is_same_type(info type1, info type2); consteval bool is_base_of_type(info type_base, info type_derived); consteval bool is_virtual_base_of_type(info type_base, info type_derived); consteval bool is_convertible_type(info type_src, info type_dst); consteval bool is_nothrow_convertible_type(info type_src, info type_dst); consteval bool is_layout_compatible_type(info type1, info type2); consteval bool is_pointer_interconvertible_base_of_type(info type_base, info type_derived); template<reflection_range R = initializer_list<info>> consteval bool is_invocable_type(info type, R&& type_args); template<reflection_range R = initializer_list<info>> consteval bool is_invocable_r_type(info type_result, info type, R&& type_args); template<reflection_range R = initializer_list<info>> consteval bool is_nothrow_invocable_type(info type, R&& type_args); template<reflection_range R = initializer_list<info>> consteval bool is_nothrow_invocable_r_type(info type_result, info type, R&& type_args); // associated with [meta.trans.cv], const-volatile modifications consteval info remove_const(info type); consteval info remove_volatile(info type); consteval info remove_cv(info type); consteval info add_const(info type); consteval info add_volatile(info type); consteval info add_cv(info type); // associated with [meta.trans.ref], reference modifications consteval info remove_reference(info type); consteval info add_lvalue_reference(info type); consteval info add_rvalue_reference(info type); // associated with [meta.trans.sign], sign modifications consteval info make_signed(info type); consteval info make_unsigned(info type); // associated with [meta.trans.arr], array modifications consteval info remove_extent(info type); consteval info remove_all_extents(info type); // associated with [meta.trans.ptr], pointer modifications consteval info remove_pointer(info type); consteval info add_pointer(info type); // associated with [meta.trans.other], other transformations consteval info remove_cvref(info type); consteval info decay(info type); template<reflection_range R = initializer_list<info>> consteval info common_type(R&& type_args); template<reflection_range R = initializer_list<info>> consteval info common_reference(R&& type_args); consteval info type_underlying_type(info type); template<reflection_range R = initializer_list<info>> consteval info invoke_result(info type, R&& type_args); consteval info unwrap_reference(info type); consteval info unwrap_ref_decay(info type); consteval size_t tuple_size(info type); consteval info tuple_element(size_t index, info type); consteval size_t variant_size(info type); consteval info variant_alternative(size_t index, info type); consteval strong_ordering type_order(info type_a, info type_b); // [meta.reflection.annotation], annotation reflection consteval vector<info> annotations_of(info item); consteval vector<info> annotations_of_with_type(info item, info type); }
Unless otherwise specified, each function, and each specialization of any function template, specified in this header is a designated addressable function ([namespace.std]).
The behavior of any function specified in namespace std​::​meta is implementation-defined when a reflection of a construct not otherwise specified by this document is provided as an argument.
[Note 1: 
Values of type std​::​meta​::​info can represent implementation-specific constructs ([basic.fundamental]).
— end note]
[Note 2: 
The behavior of many of the functions specified in namespace std​::​meta have semantics that can be affected by the completeness of class types represented by reflection values.
For such functions, for any reflection r such that dealias(r) represents a specialization of a templated class with a reachable definition, the specialization is implicitly instantiated ([temp.inst]).
[Example 1: template<class T> struct X { T mem; }; static_assert(size_of(^^X<int>) == sizeof(int)); // instantiates X<int> — end example]
— end note]
Any function in namespace std​::​meta whose return type is string_view or u8string_view returns an object V such that V.data()[V.size()] equals '\0'.
[Example 2: struct C { }; constexpr string_view sv = identifier_of(^^C); static_assert(sv == "C"); static_assert(sv.data()[0] == 'C'); static_assert(sv.data()[1] == '\0'); — end example]

21.4.2 Checking string literals [meta.string.literal]

consteval bool is_string_literal(const char* p); consteval bool is_string_literal(const wchar_t* p); consteval bool is_string_literal(const char8_t* p); consteval bool is_string_literal(const char16_t* p); consteval bool is_string_literal(const char32_t* p);
Returns:

21.4.3 Promoting to static storage strings [meta.define.static]

The functions in this subclause promote compile-time storage into static storage.
template<ranges::input_range R> consteval const ranges::range_value_t<R>* define_static_string(R&& r);
Effects: Equivalent to: return extract<const ranges::range_value_t<R>*>(meta::reflect_constant_string(r));
template<ranges::input_range R> consteval span<const ranges::range_value_t<R>> define_static_array(R&& r);
Effects: Equivalent to: using T = ranges::range_value_t<R>; meta::info array = meta::reflect_constant_array(r); if (is_array_type(type_of(array))) { return span<const T>(extract<const T*>(array), extent(type_of(array))); } else { return span<const T>(); }
template<class T> consteval const remove_cvref_t<T>* define_static_object(T&& t);
Effects: Equivalent to: using U = remove_cvref_t<T>; if constexpr (is_class_type(^^U)) { return addressof(extract<const U&>(meta::reflect_constant(std::forward<T>(t)))); } else { return define_static_array(span(addressof(t), 1)).data(); }
[Note 1: 
For class types, define_static_object provides the address of the template parameter object ([temp.param]) that is template-argument equivalent to t.
— end note]

21.4.4 Operator representations [meta.reflection.operators]

enum class operators { see below; }; using enum operators;
The enumeration type operators specifies constants used to identify operators that can be overloaded, with the meanings listed in Table 63.
The values of the constants are distinct.
Table 63 — Enum classoperators[tab:meta.reflection.operators]
Constant
Corresponding operator-function-id
Operator symbol name
op_new
operator new
new
op_delete
operator delete
delete
op_array_new
operator new[]
new[]
op_array_delete
operator delete[]
delete[]
op_co_await
operator co_await
co_await
op_parentheses
operator()
()
op_square_brackets
operator[]
[]
op_arrow
operator->
->
op_arrow_star
operator->*
->*
op_tilde
operator
op_exclamation
operator!
!
op_plus
operator+
+
op_minus
operator-
-
op_star
operator*
*
op_slash
operator/
/
op_percent
operator%
%
op_caret
operator^
^
op_ampersand
operator&
&
op_equals
operator=
=
op_pipe
operator|
|
op_plus_equals
operator+=
+
op_minus_equals
operator-=
-
op_star_equals
operator*=
*
op_slash_equals
operator/=
/
op_percent_equals
operator%=
%
op_caret_equals
operator^=
^=
op_ampersand_equals
operator&=
&
op_pipe_equals
operator|=
|
op_equals_equals
operator==
==
op_exclamation_equals
operator!=
!=
op_less
operator<
<
op_greater
operator>
>
op_less_equals
operator<=
<=
op_greater_equals
operator>=
>=
op_spaceship
operator<=>
<=>
op_ampersand_ampersand
operator&&
&&
op_pipe_pipe
operator||
||
op_less_less
operator<<
<<
op_greater_greater
operator>>
>>
op_less_less_equals
operator<<=
<<=
op_greater_greater_equals
operator>>=
>>=
op_plus_plus
operator++
++
op_minus_minus
operator--
--
op_comma
operator,
,
consteval operators operator_of(info r);
Constant When: r represents an operator function or operator function template.
Returns: The value of the enumerator from the operators whose corresponding operator-function-id is the unqualified name of the entity represented by r.
consteval string_view symbol_of(operators op); consteval u8string_view u8symbol_of(operators op);
Constant When: The value of op corresponds to one of the enumerators in operators.
Returns: A string_view or u8string_view containing the characters of the operator symbol name corresponding to op, respectively encoded with the ordinary literal encoding or with UTF-8.

21.4.5 Reflection names and locations [meta.reflection.names]

consteval bool has_identifier(info r);
Returns:
  • If r represents an entity that has a typedef name for linkage purposes ([dcl.typedef]), then true.
  • Otherwise, if r represents an unnamed entity, then false.
  • Otherwise, if r represents a class type, then !has_template_arguments(r).
  • Otherwise, if r represents a function, then true if has_template_arguments(r) is false and the function is not a constructor, destructor, operator function, or conversion function.
    Otherwise, false.
  • Otherwise, if r represents a template, then true if r does not represent a constructor template, operator function template, or conversion function template.
    Otherwise, false.
  • Otherwise, if r represents the parameter of a function F that is an (implicit or explicit) specialization of a templated function T and the parameter of the instantiated declaration of T whose template arguments are those of F would be instantiated from a pack, then false.
  • Otherwise, if r represents the parameter P of a function F, then let S be the set of declarations, ignoring any explicit instantiations, that precede some point in the evaluation context and that declare either F or a templated function of which F is a specialization; true if
    • there is a declaration D in S that introduces a name N for either P or the parameter corresponding to P in the templated function that D declares and
    • no declaration in S does so using any name other than N.
    Otherwise, false.
    [Example 1: void fun(int); constexpr std::meta::info r = parameters_of(^^fun)[0]; static_assert(!has_identifier(r)); void fun(int x); static_assert(has_identifier(r)); void fun(int x); static_assert(has_identifier(r)); void poison() { void fun(int y); } static_assert(!has_identifier(r)); — end example]
  • Otherwise, if r represents a variable, then false if the declaration of that variable was instantiated from a function parameter pack.
    Otherwise, !has_template_arguments(r).
  • Otherwise, if r represents a structured binding, then false if the declaration of that structured binding was instantiated from a structured binding pack.
    Otherwise, true.
  • Otherwise, if r represents a type alias, then !has_template_arguments(s).
  • Otherwise, if r represents an enumerator, non-static-data member, namespace, or namespace alias, then true.
  • Otherwise, if r represents a direct base class relationship, then has_identifier(type_of(r)).
  • Otherwise, r represents a data member description ([class.mem.general]); true if N is not ⊥.
    Otherwise, false.
consteval string_view identifier_of(info r); consteval u8string_view u8identifier_of(info r);
Let E be UTF-8 for u8identifier_of, and otherwise the ordinary literal encoding.
Constant When: has_identifier(r) is true and the identifier that would be returned (see below) is representable by E.
Returns: An ntmbs, encoded with E, determined as follows:
  • If r represents an entity with a typedef name for linkage purposes, then that name.
  • Otherwise, if r represents a literal operator or literal operator template, then the ud-suffix of the operator or operator template.
  • Otherwise, if r represents the parameter P of a function F, then let S be the set of declarations, ignoring any explicit instantiations, that precede some point in the evaluation context and that declare either F or a templated function of which F is a specialization; the name that was introduced by a declaration in S for the parameter corresponding to P.
  • Otherwise, if r represents an entity, then the identifier introduced by the declaration of that entity.
  • Otherwise, if r represents a direct base class relationship, then identifier_of(type_of(r)) or u8identifier_of(type_of(r)), respectively.
  • Otherwise, r represents a data member description ([class.mem.general]); a string_view or u8string_view, respectively, containing the identifier N.
consteval string_view display_string_of(info r); consteval u8string_view u8display_string_of(info r);
Returns: An implementation-defined string_view or u8string_view, respectively.
Recommended practice: Where possible, implementations should return a string suitable for identifying the represented construct.
consteval source_location source_location_of(info r);
Returns: If r represents a value, a type other than a class type or an enumeration type, the global namespace, or a data member description, then source_location{}.
Otherwise, an implementation-defined source_location value.
Recommended practice: If r represents an entity with a definition that is reachable from the evaluation context, a value corresponding to a definition should be returned.

21.4.6 Reflection queries [meta.reflection.queries]

consteval bool has-type(info r); // exposition only
Returns: true if r represents a value, annotation, object, variable, function whose type does not contain an undeduced placeholder type and that is not a constructor or destructor, enumerator, non-static data member, unnamed bit-field, direct base class relationship, data member description, or function parameter.
Otherwise, false.
consteval bool type_of(info r);
Constant When: has-type(r) is true.
Returns:
  • If r represents the parameter of a function F, then the type in the parameter-type-list of F ([dcl.fct]).
  • Otherwise, if r represents a value, object, variable, function, non-static data member, or unnamed bit-field, then the type of what is represented by r.
  • Otherwise, if r represents an annotation, then type_of(constant_of(r)).
  • Otherwise, if r represents an enumerator N of an enumeration E, then:
    • If E is defined by a declaration D that precedes a point P in the evaluation context and P does not occur within an enum-specifier of D, then a reflection of E.
    • Otherwise, a reflection of the type of N prior to the closing brace of the enum-specifier as specified in [dcl.enum].
  • Otherwise, if r represents a direct base class relationship , then a reflection of B.
  • Otherwise, for a data member description ([class.mem.general]), a reflection of the type T.
consteval info object_of(info r);
Constant When: r is a reflection representing either
  • an object with static storage duration ([basic.stc.general]), or
  • a variable that either declares or refers to such an object, and if that variable is a reference R, then either
    • R is usable in constant expressions ([expr.const]), or
    • the lifetime of R began within the core constant expression currently under evaluation.
Returns:
  • If r represents an object, then r.
  • Otherwise, if r represents a reference, then a reflection of the object referred to by that reference.
  • Otherwise, r represents a variable; a reflection of the object declared by that variable.
[Example 1: int x; int& y = x; static_assert(^^x != ^^y); // OK, r and y are different variables so their // reflections compare different static_assert(object_of((^^x) == object_of(^^y))); // OK, because y is a reference // to x, their underlying objects are the same — end example]
consteval info constant_of(info r);
Let R be a constant expression of type info such that R == r is true.
If r represents an annotation, then let C be its underlying constant.
Constant When: Either r represents an annotation or [: R :] is a valid splice-expression ([expr.prim.splice]).
Effects: Equivalent to: if constexpr (is_annotation(R)) { return C; } else { return reflect_constant([: R :]); }
[Example 2: constexpr int x = 0; constexpr int y = 0; static_assert(^^x != ^^y); // OK, x and y are different variables, // so their reflections compare different static_assert(constant_of(^^x) == constant_of(^^y)); // OK, both constant_of(x) and // constant_of(^^y) represent the value 0 static_assert(constant_of(^^x) == reflect_constant(0)); // OK, likewise struct S { int m; }; constexpr S s {42}; static_assert(is_object(constant_of(^^s)) && is_object(reflect_object(s))); static_assert(constant_of(^^s) != // OK, template parameter object that is template-argument- reflect_object(s)); // equivalent to s is a different object than s static_assert(constant_of(^^s) == constant_of(reflect_object(s))); // OK consteval info fn() { constexpr int x = 42; return ^^x; } constexpr info r = constant_of(fn()); // error: x is outside its lifetime — end example]
consteval bool is_public(info r); consteval bool is_protected(info r); consteval bool is_private(info r);
Returns: true if r represents either
  • a class member or unnamed bit-field that is public, protected, or private, respectively, or
  • a direct base class relationship for which B is, respectively, a public, protected, or private base class of D.
Otherwise, false.
consteval bool is_virtual(info r);
Returns: true if r represents either a virtual member function or a direct base class relationship for which B is a virtual base class of D.
Otherwise, false.
consteval bool is_pure_virtual(info r); consteval bool is_override(info r);
Returns: true if r represents a member function that is pure virtual or overrides another member function, respectively.
Otherwise, false.
consteval bool is_final(info r);
Returns: true if r represents a final class or a final member function.
Otherwise, false.
consteval bool is_deleted(info r); consteval bool is_defaulted(info r);
Returns: true if r represents a function that is a deleted function ([dcl.fct.def.delete]) or defaulted function ([dcl.fct.def.default]), respectively.
Otherwise, false.
consteval bool is_user_provided(info r); consteval bool is_user_declared(info r);
Returns: true if r represents a function that is user-provided or user-declared ([dcl.fct.def.default]), respectively.
Otherwise, false.
consteval bool is_explicit(info r);
Returns: true if r represents a member function that is declared explicit.
Otherwise, false.
[Note 1: 
If r represents a member function template that is declared explicit, is_explicit(r) is still false because in general, such queries for templates cannot be answered.
— end note]
consteval bool is_noexcept(info r);
Returns: true if r represents a noexcept function type or a function with a non-throwing exception specification ([except.spec]).
Otherwise, false.
[Note 2: 
If r represents a function template that is declared noexcept, is_noexcept(r) is still false because in general, such queries for templates cannot be answered.
— end note]
consteval bool is_bit_field(info r);
Returns: true if r represents a bit-field, or if r represents a data member description ([class.mem.general]) for which W is not ⊥.
Otherwise, false.
consteval bool is_enumerator(info r); consteval bool is_annotation(info r);
Returns: true if r represents an enumerator or annotation, respectively.
Otherwise, false.
consteval bool is_const(info r); consteval bool is_volatile(info r);
Returns: true if r represents a const or volatile type, respectively, or a const- or volatile-qualified function type, respectively.
Otherwise, false.
consteval bool is_mutable_member(info r);
Returns: true if r represents a mutable non-static data member.
Otherwise, false.
consteval bool is_lvalue_reference_qualified(info r); consteval bool is_rvalue_reference_qualified(info r);
Let T be type_of(r) if has-type(r) is true.
Otherwise, let T be dealias(r).
Returns: true if T represents an lvalue- or rvalue-qualified function type, respectively.
Otherwise, false.
consteval bool has_static_storage_duration(info r); consteval bool has_thread_storage_duration(info r); consteval bool has_automatic_storage_duration(info r);
Returns: true if r represents an object or variable that has static, thread, or automatic storage duration, respectively ([basic.stc]).
Otherwise, false.
[Note 3: 
It is not possible to have a reflection representing an object or variable having dynamic storage duration.
— end note]
consteval bool has_internal_linkage(info r); consteval bool has_module_linkage(info r); consteval bool has_external_linkage(info r); consteval bool has_c_language_linkage(info r); consteval bool has_linkage(info r);
Returns: true if r represents a variable, function type, template, or namespace whose name has internal linkage, module linkage, C language linkage, or any linkage, respectively ([basic.link]).
Otherwise, false.
consteval bool is_complete_type(info r);
Returns: true if is_type(r) is true and there is some point in the evaluation context from which the type represented by dealias(r) is not an incomplete type ([basic.types]).
Otherwise, false.
consteval bool is_enumerable_type(info r);
A type T is enumerable from a point P if either
  • T is a class type complete at point P or
  • T is an enumeration type defined by a declaration D such that D is reachable from P but P does not occur within an enum-specifier of D ([dcl.enum]).
Returns: true if dealias(r) represents a type that is enumerable from some point in the evaluation context.
Otherwise, false.
[Example 3: class S; enum class E; static_assert(!is_enumerable_type(^^S)); static_assert(!is_enumerable_type(^^E)); class S { void mfn() { static_assert(is_enumerable_type(^^S)); } static_assert(!is_enumerable_type(^^S)); }; static_assert(is_enumerable_type(^^S)); enum class E { A = is_enumerable_type(^^E) ? 1 : 2 }; static_assert(is_enumerable_type(^^E)); static_assert(static_cast<int>(E::A) == 2); — end example]
consteval bool is_variable(info r);
Returns: true if r represents a variable.
Otherwise, false.
consteval bool is_type(info r); consteval bool is_namespace(info r);
Returns: true if r represents an entity whose underlying entity is a type or namespace, respectively.
Otherwise, false.
consteval bool is_type_alias(info r); consteval bool is_namespace_alias(info r);
Returns: true if r represents a type alias or namespace alias, respectively Otherwise, false.
[Note 4: 
A specialization of an alias template is a type alias.
— end note]
consteval bool is_function(info r);
Returns: true if r represents a function.
Otherwise, false.
consteval bool is_conversion_function(info r); consteval bool is_operator_function(info r); consteval bool is_literal_operator(info r);
Returns: true if r represents a function that is a conversion function ([class.conv.fct]), operator function ([over.oper]), or literal operator ([over.literal]), respectively.
Otherwise, false.
consteval bool is_special_member_function(info r); consteval bool is_constructor(info r); consteval bool is_default_constructor(info r); consteval bool is_copy_constructor(info r); consteval bool is_move_constructor(info r); consteval bool is_assignment(info r); consteval bool is_copy_assignment(info r); consteval bool is_move_assignment(info r); consteval bool is_destructor(info r);
Returns: true if r represents a function that is a special member function ([special]), a constructor, a default constructor, a copy constructor, a move constructor, an assignment operator, a copy assignment operator, a move assignment operator, or a destructor, respectively.
Otherwise, false.
consteval bool is_function_parameter(info r);
Returns: true if r represents a function parameter.
Otherwise, false.
consteval bool is_explicit_object_parameter(info r);
Returns: true if r represents a function parameter that is an explicit object parameter ([dcl.fct]).
Otherwise, false.
consteval bool has_default_argument(info r);
Returns: If r represenst a parameter P of a function F, then:
  • If F is a specialization of a templated function T, then true if there exists a declaration D of T that precedes some point in the evaluation context and D specifies a default argument for the parameter of T corresponding to P.
    Otherwise, false.
  • Otherwise, if there exists a declaration D of F that precedes some point in the evaluation context and D specifies a default argument for P, then true.
Otherwise, false.
consteval bool has_ellipsis_parameter(info r);
Returns: true if r represents a function type that has an ellipsis in its parameter-type-list ([dcl.fct]).
Otherwise, false.
consteval bool is_template(info r);
Returns: true if r represents a function template, class template, variable template, alias template, or concept.
Otherwise, false.
[Note 5: 
A template specialization is not a template.
For example, is_template(^^std​::​vector) is true but is_template(^^std​::​vector<int>) is false.
— end note]
consteval bool is_function_template(info r); consteval bool is_variable_template(info r); consteval bool is_class_template(info r); consteval bool is_alias_template(info r); consteval bool is_conversion_function_template(info r); consteval bool is_operator_function_template(info r); consteval bool is_literal_operator_template(info r); consteval bool is_constructor_template(info r); consteval bool is_concept(info r);
Returns: true if r represents a function template, variable template, class template, alias template, conversion function template, literal operator template, constructor template, or concept, respectively.
Otherwise, false.
consteval bool is_value(info r); consteval bool is_object(info r);
Returns: true if r represents a value or object, respectively.
Otherwise, false.
consteval bool is_structured_binding(info r);
Returns: true if r represents a structured binding.
Otherwise, false.
consteval bool is_class_member(info r); consteval bool is_namespace_member(info r); consteval bool is_nonstatic_data_member(info r); consteval bool is_static_member(info r); consteval bool is_base(info r);
Returns: true if r represents a class member, namespace member, non-static data member, static member, or direct base class relationship, respectively.
Otherwise, false.
consteval bool has_default_member_initializer(info r);
Returns: true if r represents a non-static data member that has a default member initializer.
Otherwise, false.
consteval bool has_parent(info r);
Returns:
  • If r represents the global namespace, then false.
  • Otherwise, if r represents an entity that has C language linkage ([dcl.link]), then false.
  • Otherwise, if r represents an enitity that has a language linkage other than C++ language linkage, then an implementation-defined value.
  • Otherwise, if r represents a type that is neither a class nor enumeration type, then false.
  • Otherwise, if r represents an enity or direct base class relationship, then true.
  • Otherwise, false.
consteval info parent_of(info r);
Constant When: has_parent(r) is true.
Returns:
  • If r represents a non-static data member that is a direct member of an anonymous union, or an unnamed bit-field declared within the member-specification of such a union, then a reflection representing the innermost enclosing anonymous union.
  • Otherwise, if r represents an enumerator, then a reflection representing the corresponding enumeration type.
  • Otherwise, if r represents a direct base class relationship , then a reflection representing D.
  • Otherwise, let E be a class, function, or namespace whose class scope, function parameter scope, or namespace scope, respectively, is the innermost such scope that either is, or encloses, the target scope of a declaration of what is represented by r.
    • If E is the function call oeprator of a closure type for a consteval-block-declaration ([dcl.pre]), then parent_of(​parent_of(^^E)).
      [Note 6: 
      In this case, the first parent_of will be the closure type, so the second parent_of is necessary to give the parent of that closure type.
      — end note]
    • Otherwise, ^^E.
[Example 4: struct I { }; struct F : I { union { int o; }; enum N { A }; }; constexpr auto ctx = std::meta::access_context::current(); static_assert(parent_of(^^F) == ^^::); static_assert(parent_of(bases_of(^^F, ctx)[0]) == ^^F); static_assert(is_union_type(parent_of(^^F::o))); static_assert(parent_of(^^F::N) == ^^F); static_assert(parent_of(^^F::A) == ^^F::N); — end example]
consteval info dealias(info r);
Constant When: r represents an entity.
Returns: A reflection representing the underlying entity of what r represents.
[Example 5: using X = int; using Y = X; static_assert(dealias(^^int) == ^^int); static_assert(dealias(^^X) == ^^int); static_assert(dealias(^^Y) == ^^int); — end example]
consteval bool has_template_arguments(info r);
Returns: true if r represents a specialization of a function template, variable template, class template, or an alias template.
Otherwise, false.
consteval info template_of(info r);
Constant When: has_template_arguments(r) is true.
Returns: A reflection of the template of the specialization represented by r.
consteval vector<info> template_arguments_of(info r);
Constant When: has_template_arguments(r) is true.
Returns: A vector containing reflections of the template arguments of the template specialization represented by r, in the order in which they appear in the corresponding template argument list.
For a given template argument A, its corresponding reflection R is determined as follows:
  • If A denotes a type or type alias, then R is a reflection representing the underlying entity of A.
    [Note 7: 
    R always represents a type, never a type alias.
    — end note]
  • Otherwise, if A denotes a class template, variable template, concept, or alias template, then R is a reflection representing A.
  • Otherwise, A is a constant template argument ([temp.arg.nontype]).
    Let P be the corresponding template parameter.
    • If P has reference type, then R is a reflection representing the object or function referred to by A.
    • Otherwise, if P has class type, then R represents the corresponding template parameter object.
    • Otherwise, R is a reflection representing the value of A.
[Example 6: template<class T, class U = T> struct Pair { }; template<class T> struct Pair<char, T> { }; template<class T> using PairPtr = Pair<T*>; static_assert(template_of(^^Pair<int>) == ^^Pair<int>); static_assert(template_of(^^Pair<char, char>) == ^^Pair); static_assert(template_arguments_of(^^Pair<int>).size() == 2); static_assert(template_arguments_of(^^Pair<int>)[0] == ^^int); static_assert(template_of(^^PairPtr<int>) == ^^PairPtr); static_assert(template_arguments_of(^^PairPtr<int>).size() == 1); struct S { }; int i; template<int, int&, S, template<class> class> struct X { }; constexpr auto T = ^^X<1, i, S{}, PairPtr>; static_assert(is_value(template_arguments_of(T)[0])); static_assert(is_object(template_arguments_of(T)[1])); static_assert(is_object(template_arguments_of(T)[2])); static_assert(template_arguments_of(T)[3] == ^^PairPtr); — end example]
consteval vector<info> parameters_of(info r);
Constant When: r represents a function or a function type.
Returns:
  • If r represents a function F, then a vector containing reflections of the parameters of F, in the order in which they appear in a declaration of F.
  • Otherwise, r represents a function type T; a vector containing reflections of the types in parameter-type-list ([dcl.fct]) of T, in the order in which they appear in the parameter-type-list.
consteval info variable_of(info r);
Constant When:
  • r represents a parameter of a function F and
  • there is a point P in the evaluation context for which the innermost non-block scope enclosing P is the function parameter scope ([basic.scope.param]) associated with F.
Returns: The reflection of the parameter variable corresponding to r.
consteval info return_type_of(info r);
Constant When: Either r represents a function and has-type(r) is true or r represents a function type.
Returns: The reflection of the return type of the function or function type represented by r.

21.4.7 Access control context [meta.reflection.access.context]

The access_context class is a non-aggregate type that represents a namespacee, class, or function from which queries pertaining to access rules may be performed, as well as the designating class ([class.access.base]), if any.
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; }; }
access_context is a structural type.
Two values ac1 and ac2 of type access_context are template-argument-equivalent ([temp.type]) if a1.scope() and a2.scope() are template-argument-equivalent and ac1.designating_class() and ac2.designating_class() are template-argument-equivalent.
consteval info scope() const; consteval info designating_class() const;
Returns: The access_context's associated scope and designating class, respectively.
static consteval access_context current() noexcept;
Given a program point P, let eval-point(P) be the following program point:
  • If a potentially-evaluated subexpression ([intro.execution]) of a default member initializer I for a member of class C ([class.mem.general]) appears at P, then a point determined as follows:
    • If an aggregate initialization is using I, eval-point(Q), where Q is the point at which that aggregate initialization appears.
    • Otherwise, if an initialization by an inherited constructor ([class.inhctor.init]) is using I, a point whose immediate scope is the class scope corresponding to C.
    • Otherwise, a point whose immediate scope is the function parameter scope corresponding to the constructor definition that is using I.
  • Otherwise, if a potentially-evaluated subexpression of a default argument ([dcl.fct.default]) appears at P, eval-point(Q), where Q is the point at which the invocation of the function ([expr.call]) using that default argument appears.
  • Otherwise, if the immediate scope of P is a function parameter scope introduced by a declaration D, and P appears either before the locus of D or within the trailing requires-clause of D, a point whose immediate scope is the innermost scope enclosing the locus of D that is not a template parameter scope.
  • Otherwise, if the immediate scope of P is a function parameter scope introduced by a lambda-expression L whose lambda-introducer appears at point Q, and P appears either within the trailing-return-type or the trailing requires-clause of L, eval-point(Q).
  • Otherwise, if the innermost non-block scope enclosing P is the function parameter scope introduced by a consteval-block-declaration ([dcl.pre]), a point whose immediate scope is that inhabited by the outermost consteval-block-declaration D containing P such that each scope (if any) that intervenes between P and the function parameter scope introduced by D is either
  • Otherwise, P.
Given a scope S, let ctx-scope(S) be the following scope:
  • If S is a class scope or namespace scope, S.
  • Otherwise, if S is a function parameter scope introduced by the declaration of a function, S.
  • Otherwise, if S is a lambda scope introduced by a lambda-expression L, the function parameter scope corresponding to the call operator of the closure type of L.
  • Otherwise, ctx-scope(), where is the parent scope of S.
Returns: An access_context whose designating class is the null reflection and whose scope represents the function, class, or namespace whose corresponding function parameter scope, class scope, or namespace scope, respectively, is ctx-scope(S), where S is the immediate scope of eval-point(P) and P is the point at which the invocation of current lexically appears.
[Example 1: struct A { int a = 0; consteval A(int p) : a(p) {} }; struct B : A { using A::A; consteval B(int p, int q) : A(p * q) {} info s = access_context::current().scope(); }; struct C : B { using B::B; }; struct Agg { consteval bool eq(info rhs = access_context::current().scope()) { return s == rhs; } info s = access_context::current().scope(); }; namespace NS { static_assert(Agg{}.s == access_context::current().scope()); // OK static_assert(Agg{}.eq()); // OK static_assert(B(1).s == ^^B); // OK static_assert(is_constructor(B{1, 2}.s) && parent_of(B{1, 2}.s) == ^^B); // OK static_assert(is_constructor(C{1, 2}.s) && parent_of(C{1, 2}.s) == ^^B); // OK auto fn() -> [:is_namespace(access_context::current().scope()) ? ^^int : ^^bool:]; static_assert(type_of(^^fn) == ^^auto()->int); // OK template<auto R> struct TCls { consteval bool fn() requires (is_type(access_context::current().scope())) { return true; // OK, scope is TCls<R>. } }; static_assert(TCls<0>{}.fn()); // OK } — end example]
Remarks: current is not an addressable function ([namespace.std]).
An invocation of current that appears at a program point P is value-dependent ([temp.dep.constexpr]) if eval-point(P) is enclosed by a scope corresponding to a templated entity.
static consteval access_context unprivileged() noexcept;
Returns: An access_context whose designating class is the null reflection and whose scope is the global namespace.
static consteval access_context unchecked() noexcept;
Returns: An access_context whose designating class and scope are both the null reflection.
static consteval access_context via(info cls) noexcept;
Constant When: cls is either the null reflection or a reflection of a complete class type.
Returns: An access_context whose scope is this->scope() and whose designating class is cls.

21.4.8 Member accessibility queries [meta.reflection.access.queries]

consteval bool is_accessible(info r, access_context ctx);
Let PARENT-CLS(r) be:
  • If parent_of(r) represents a class C, then C.
  • Otherwise, PARENT-CLS(parent_of(r)).
Constant When:
  • r does not represent a class member for which PARENT-CLS(r) is an incomplete class and
  • r does not represent a direct base class relationship for which D is incomplete.
Let DESIGNATING-CLS(r, ctx) be:
  • If ctx.designating_class() represents a class C, then C.
  • Otherwise, PARENT-CLS(r).
Returns:
  • If r represents an unnamed bit-field F, then is_accessible(, ctx), where represents a hypothetical non-static data member of the class represented by PARENT-CLS(r) with the same access as F.
    [Note 1: 
    Unnamed bit-fields are treated as class members for the purpose of is_accessible.
    — end note]
  • Otherwise, if r does not represent a class member or a direct base class relationship, then true.
  • Otherwise, if r represents
    • a class member that is not a (possibly indirect or variant) member of DESIGNATING-CLS(​r, ctx) or
    • a direct base class relationship such that parent_of(r) does not represent DESIGNATING-CLS(​r, ctx) or a (direct or indirect) base class thereof,
    then false.
  • Otherwise, if ctx.scope() is the null reflection, then true.
  • Otherwise, letting P be a program point whose immediate scope is the function parameter scope, class scope, or namespace scope corresponding to the function, class, or namespace represented by ctx.scope():
[Note 2: 
The definitions of when a class member or base class is accessible from a point P do not consider whether a declaration of that entity is reachable from P.
— end note]
[Example 1: consteval access_context fn() { return access_context::current(); } class Cls { int mem; friend consteval access_context fn(); public: static constexpr auto r = ^^mem; }; static_assert(is_accessible(Cls::r, fn())); // OK static_assert(!is_accessible(Cls::r, access_context::current())); // OK static_assert(is_accessible(Cls::r, access_context::unchecked())); // OK — end example]
consteval bool has_inaccessible_nonstatic_data_members(info r, access_context ctx);
Constant When:
  • nonstatic_data_members_of(​r, access_context​::​​unchecked()) is a constant subexpression and
  • r does not represent a closure type.
Returns: true if is_accessible(R, ctx) is false for any R in nonstatic_data_members_of(​r, access_context​​::​unchecked()).
Otherwise, false.
consteval bool has_inaccessible_bases(info r, access_context ctx);
Constant When: bases_of(r, access:context​::​unchecked()) is a constant subexpression.
Returns: true if is_accessible(R, ctx) is false for any R in bases_of(​r, access_context​::​​unchecked()).
Otherwise, false.
consteval bool has_inaccessible_subobjects(info r, access_context ctx);
Effects: Equivalent to: return has_inaccessible_bases(r, ctx) || has_inaccessible_nonstatic_data_members(r, ctx);

21.4.9 Reflection member queries [meta.reflection.member.queries]

consteval vector<info> members_of(info r, access_context ctx);
Constant When: dealias(r) is a reflection representing either a class type that is complete from some point in the evaluation context or a namespace.
A declaration D members-of-precedes a point P if D precedes either P or the point immediately following the class-specifier of the outermost class for which P is in a complete-class context.
A declaration D of a member M of a class or namespace Q is Q-members-of-eligible if
It is implementation-defined whether declarations of other members of a closure type Q are Q-members-of-eligible.
A member M of a class or namespace Q is Q-members-of-representable from a point P if a Q-members-of-eligible declaration of M members-of-precedes P, and M is
  • a class or enumeration type
  • a type alias
  • a class template, function template, variable template, alias template, or concept,
  • a variable or reference V for which the type of V 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, F is the selected destructor ([class.dtor]),
  • a non-static data member,
  • a namesapce, or
  • a namespace alias.
[Note 1: 
Examples of direct members that are not Q-members-of-representable for any entity Q include: unscoped enumerators ([enum]), partial specializations of templates ([temp.spec.partial]), and closure types ([expr.prim.lambda.closure]).
— end note]
Returns: A vector containing reflections of all members M of the entity Q represented by dealias(r) for which
  • M is Q-members-of-representable from some point in the evaluation context and
  • is_accessible(^^M, ctx) is true.
If dealias(r) represents a class C, then the vector also contains reflections representing all unnamed bit-fields B whose declarations inhabit the class scope corresponding to C for which is_accessible(^^B, ctx) is true.
Reflections of class members and unnamed bit-fields that are declared appear in the order in which they are declared.
[Note 2: 
Base classes are not members.
Implicitly-declared special members appear after any user-declared members ([special]).
— end note]
[Example 1: // TU1 export module M; namespace NS { export int m; static int l; } static_assert(members_of(^^NS, access_context::current()).size() == 2); // TU2 import M; static_assert( // NS​::​l does not precede members_of(^^NS, access_context::current()).size() == 1); // the constant-expression ([basic.lookup]) class B {}; struct S : B { private: class I; public: int m; }; static_assert( // 6 special members, members_of(^^S, access_context::current()).size() == 7); // 1 public member, // does not include base static_assert( // all of the above, members_of(^^S, access_context::unchecked()).size() == 8); // as well as a reflection // representing S​::​I — end example]
consteval vector<info> bases_of(info type, access_context ctx);
Constant When: dealias(type) represents a class type that is complete from some point in the evaluation context.
Returns: Let C be the class represented by dealias(type).
A vector containing the reflections of all the direct base class relationships of B, if any, of C such that is_accessible(^^B, txt) is true.
The direct base class relationships appear in the order in which the corresponding base classes appear in the base-specifier-list of C.
consteval vector<info> static_data_members_of(info type, access_context ctx);
Constant When: dealias(type) represents a class type that is complete from some point in the evaluation context.
Returns: A vector containing each element e of members_of(type, ctx) such that is_variable(e) is true, preserving their order.
consteval vector<info> nonstatic_data_members_of(info type, access_context ctx);
Constant When: dealias(type) represents a class type that is complete from some point in the evaluation context.
Returns: A vector containing each element e of members_of(type, ctx) such that is_nonstatic_data_members_of(e) is true, preserving their order.
consteval vector<info> subobjects_of(info type, access_context ctx);
Constant When: dealias(type) represents a class type that is complete from some point in the evaluation context.
Returns: A vector containing each element of bases_of(type, ctx) followed by each element of nonstatic_data_members_of(​type,​ ctx), preserving their order.
consteval vector<info> enumerators_of(info type_enum);
Constant When: dealias(type_enum) represents an enumeration type, and is_enumerable_type(​type_enum) is true.
Returns: A vector containing the reflections of each enumerator of the enumeration represented by dealias(type_enum), in the order in which they are declared.

21.4.10 Reflection layout queries [meta.reflection.layout]

struct member_offset { ptrdiff_t bytes; ptrdiff_t bits; constexpr ptrdiff_t total_bits() const; auto operator<=>(const member_offset&) const = default; }; constexpr ptrdiff_t member_offset::total_bits() const;
Returns: bytes * CHAR_BIT + bits.
consteval member_offset offset_of(info r);
Constant When: r represents a non-static data member, unnamed bit-field, or direct base class relationship for which either B is not a virtual base class or D is not an abstract class.
Let V be the offset in bits from the beginning of a complete object of the type represented by parent_of(r) to the subobject associated with the entity represented by r.
Returns: {V / CHAR_BIT, V % CHAR_BIT}.
consteval size_t size_of(info r);
Constant When: dealias(r) is a reflection of a type, object, value, variable of non-reference type, non-static data member that is not a bit-field, direct base class relationship, or data member description ([class.mem.general]) where W is not ⊥.
If dealias(r) represents a type, then is_complete_type(r) is true.
Returns: If r represents
  • a non-static data member of type T,
  • a data member description , or
  • dealias(r) represents a type T,
then sizeof(T) if T is not a reference type and size_of(​add_pointer(^^T)) otherwise.
Otherwise, size_of(type_of(r)).
[Note 1: 
It is possible that while sizeof(char)== size_of(^^char) is true, that sizeof(char&)== size_of(^^char&) is false.
If b represents a direct base class relationship of an empty base class, then size_of(b) > 0 is true.
— end note]
consteval size_t alignment_of(info r);
Constant When: dealias(r) is a reflection of a type, object, value, variable of non-reference type, non-static data member that is not a bit-field, direct base class relationship, or data member description.
If dealias(r) represents a type, then is_complete_type(r) is true.
Returns:
  • If dealias(r) represents a type T, then the alignment requirement for the layout-associated type ([class.mem.general]) for a non-static data member of type T.
  • Otherwise, if dealias(r) represents a variable or object, then the alignment requirement of the variable or object.
  • Otherwise, if r represents a direct base class relationship, then alignment_of(type_of(r)).
  • Otherwise, if r represents a non-static data member, then the alignment requirement of the subobject associated with the represented entity within any object of type parent_of(r).
  • Otherwise, r represents a data member description ([class.mem.general]).
    If A is not ⊥, then the value of A.
    Otherwise, alignment_of(^^T).
consteval size_t bit_size_of(info r);
Constant When: dealias(r) is a reflection of a type, object, value, variable of non-reference type, non-static data member, unnamed bit-field, direct base class relationship, or data member description.
If dealias(r) represents a type T, there is a point within the evaluation context from which T is not incomplete.
Returns:
  • If r represents an unnamed bit-field or a non-static data member that is a bit-field with width W, then W.
  • Otherwise, if r represents a data member description ([class.mem.general]) and W is not ⊥, then W.
  • Otherwise, CHAR_BIT * size_of(r).

21.4.11 Value extraction [meta.reflection.extract]

The extract function template may be used to extract a value out of a reflection when its type is known.
The following are defined for exposition only to aid in the specification of extract.
template<class T> consteval T extract-ref(info r); // exposition only
[Note 1: 
T is a reference type.
— end note]
Constant When:
  • r represents a variable or object of type U,
  • is_convertible_v<remove_reference_t<U>(*)[],​ remove_reference_t<​T>(*)[]> is true,
    and
    [Note 2: 
    The intent is to allow only qualification conversion from U to T.
    — end note]
  • If r represents a variable, then either that variable is usable in constant expressions or its lifetime began within the core constant expression currently under evaluation.
Returns: If r represents an object O, then a reference ot O.
Otherwise, a reference to the object declared, or referred to, by the variable represented by r.
template<class T> consteval T extract-member-or-function(info r); // exposition only
Constant When:
  • r represents a non-static data member with type X, that is not a bit-field, that is a direct member of class C, T and C are similar types ([conv.qual]), and T is is_convertible_v<​X C​::​*, T> is true;
  • r represents an implicit object member function with type F or F noexcept that is a direct member of a class C, and T is F C​::​*; or
  • r represents a non-member function, static member function, or explicit object member function of function type F or F noexcept, and T is F*.
Returns:
  • If T is a pointer type, then a pointer value pointing to the function represented by r.
  • Otherwise, a pointer-to-member value designating the non-static data member or function represented by r.
template<class T> consteval T extract-value(info r); // exposition only
Let U be the type of the value or object that r represents.
Constant When:
  • U is a pointer type, T and U are similar types ([conv.qual]), and is_convertible_v<​U, T> is true,
  • U is not a pointer type and the cv-unqualified types of T and U are the same,
  • U is an array type, T is a pointer type, and the value r represents is convertible to T, or
  • U is a closure type, T is a function pointer type, and the value that r represents is convertible to T.
Returns: static_cast<T>([:R:]), where R is a constant expression of type info such that R == r is true.
template<class T> consteval T extract(info r);
Let U be remove_cv_t<T>.
Effects: Equivalent to: if constexpr (is_reference_type(^^T)) { return extract-ref<T>(r); } else if constexpr (is_nonstatic_data_member(r) || is_function(r)) { return extract-member-or-function<U>(r); } else { return extract-value<U>(constant_of(r)); }

21.4.12 Reflection substitution [meta.reflection.substitute]

template<class R> concept reflection_range = ranges::input_range<R> && same_as<ranges::range_value_t<R>, info> && same_as<remove_cvref_t<ranges::range_reference_t<R>>, info>; template<reflection_range R = initializer_list<info>> consteval bool can_substitute(info templ, R&& arguments);
Constant When: templ represents a template, and every reflection in arguments represents a construct usable as a template argument ([temp.arg]).
Let Z be the template represented by templ and let Args... be a sequence of prvalue constant expressions that compute the reflections held by the elements of arguments.
Returns: true if Z<[:Args:]...> is a valid template-id ([temp.names]) that does not name a function whose type contains an undeduced placeholder type.
Otherwise, false.
[Note 1: 
If forming Z<[:Args:]...> leads to a failure outside of the immediate context, the program is ill-formed.
— end note]
template<reflection_range R = initializer_list<info>> consteval info substitute(info templ, R&& arguments);
Constant When: can_substitute(templ, arguments) is true.
Let Z be the template represented by templ and let Args... be a sequence of prvalue constant expressions that compute the reflections held by the elements of arguments.
Returns: ^^Z<[:Args:]...>.
[Note 2: 
If forming Z<[:Args:]...> leads to a failure outside of the immedaite context, the program is ill-formed.
— end note]
[Example 1: template<class T> auto fn1(); static_assert(!can_substitute(^^fn1, {^^int})); // OK constexpr info r1 = substitute(^^fn1, {^^int}); // error: fn<int> contains an undeduced // placeholder type template<class T> auto fn2() { static_assert(^^T != ^^int); // static assertion failed during instantiation of fn<int> return 0; } constexpr bool r2 = can_substitute(^^fn2, {^^int}); // error: instantiation of body of fn<int> // is needed to deduce return type — end example]
[Example 2: consteval info to_integral_constant(unsigned i) { return substitute(^^integral_constant, {^^unsigned, reflect_constant(i)}); } constexpr info r = to_integral_constant(2); // OK, r represents the type // integral_constant<unsigned, 2> — end example]

21.4.13 Expression result reflection [meta.reflection.result]

template<class T> consteval info reflect_constant(T expr);
Mandates: is_copy_constructible_v<T> is true and T is a cv-unqualified structural type ([temp.param]) that is not a reference type.
Let V be:
  • if T is a class type, then an object that is template-argument-equivalent to the value of expr;
  • otherwise, the value of expr.
Constant When: given the invented variable template<T P> struct TCls; the template-id TCls<V> would be valid.
Returns: template_arguments_of(^^TCls<V>)[0].
[Note 1: 
This is a reflection of an object for class types, and a reflection of a value otherwise.
— end note]
[Example 1: template<auto D> struct A { }; struct N { int x; }; struct K { char const* p; }; constexpr info r1 = reflect_constant(42); static_assert(is_value(r1)); static_assert(r1 == template_arguments_of(^^A<42>)[0]); constexpr info r2 = reflect_constant(N{42}); static_assert(is_object(r2)); static_assert(r2 == template_arguments_of(^^A<N{42}>)[0]); constexpr info r3 = reflect_constant(K{nullptr}); // OK constexpr info r4 = reflect_constant(K{"ebab"}); // error: constituent pointer // points to string literal — end example]
template<class T> consteval info reflect_object(T& expr);
Mandates: T is an object type.
Constant When: expr is suitable for use as a constant template argument for a constant template parameter of type T& ([temp.arg.nontype]).
Returns: A reflection of the object designated by expr.
template<class T> consteval info reflect_function(T& expr);
Mandates: T is a function type.
Constant When: expr is suitable for use as a constant template argument for a constant template parameter of type T& ([temp.arg.nontype]).
Returns: A reflection of the function designated by fn.

21.4.14 Promoting to static storage arrays [meta.reflection.array]

The functions in this subclause promote compile-time storage into static storage.
template<ranges::input_range R> consteval info reflect_constant_string(R&& r);
Let CharT be ranges​::​range_value_t<R>.
Mandates: CharT is one of char, wchar_t, char8_t, char16_t, char32_t.
Let V be the pack of values of type CharT whose elements are the corresponding elements of r, except that if r refers to a string literal object, then V does not include the trailing null terminator of r.
Let P be the template parameter object ([temp.param]) of type const CharT[sizeof...(V)+1] initialized with V..., CHART().
Returns: ^^P.
[Note 1: 
P is a potentially non-unique object ([intro.object]).
— end note]
template<ranges::input_range R> consteval info reflect_constant_array(R&& r);
Let T be ranges​::​range_value_t<R>.
Mandates: T is a structural type ([temp.param]), is_constructible_v<T, ranges​::​range_reference_t<R>> is true, and is_copy_constructible_v<T> is true.
Constant When: reflect_constant(e) is a constant subexpression for every element e of r.
Let V be the pack of values of type info of the same size as r, where the element is reflect_constant(), where is the element of r.
Let P be
  • If sizeof...(V) > 0 is true, then the template parameter object ([temp.param]) of type const T[sizeof...(V)] initialized with {[:V:]...}.
  • Otherwise, the template parameter object of type array<T, 0> initialized with {}.
Returns: ^^P.
[Note 2: 
P is a potentially non-unique object ([intro.object]).
— end note]

21.4.15 Reflection class definition generation [meta.reflection.define.aggregate]

namespace std::meta { struct data_member_options { struct name-type { // exposition only template<class T> requires constructible_from<u8string, T> consteval name-type(T&&); template<class T> requires constructible_from<string, T> consteval name-type(T&&); private: variant<u8string, string> contents; // exposition only }; optional<name-type> name; optional<int> alignment; optional<int> bit_width; bool no_unique_address = false; }; }
The classes data_member_options and data_member_options​::​name-type are consteval-only types ([basic.types.general]), and are not structural types ([temp.param]).
template<class T> requires constructible_from<u8string, T> consteval data_member_options::name-type(T&& value);
Effects: Initializes contents with u8string(std​::​forward<T>(value)).
template<class T> requires constructible_from<string, T> consteval data_member_options::name-type(T&& value);
Effects: Initializes contents with string(std​::​forward<T>(value)).
[Note 1: 
The class name-type allows the function data_member_spec to accept an ordinary string literal (or string_view, string, etc.)
or a UTF-8 string literal (or u8string_view, u8string, etc.)
equally well.
[Example 1: consteval void fn() { data_member_options o1 = {.name = "ordinary_literal_encoding"}; data_member_options o2 = {.name = u8"utf8_encoding"}; } — end example]
— end note]
consteval info data_member_spec(info type, data_member_options options);
Constant When:
  • dealias(type) represents eitehr an object type or a reference type;
  • if options.name contains a value, then:
    • holds_alternative<u8string>(options.name->contents) is true and get<u8string>(​options.name->​contents) contains a valid identifier ([lex.name]) that is not a keyword ([lex.key]) when interpreted with UTF-8, or
    • holds_alternative<string>(options.name->contents) is true and get<string>(
      options.name->contents)
      contains a valid identifier ([lex.name]) that is not a keyword ([lex.key]) when interpreted with the ordinary literal encoding;
    [Note 2: 
    The name corresponds to the spelling of an identifier token after phase 6 of translation ([lex.phases]).
    Lexical constructs like universal-character-names ([lex.universal.char]) are not processed and will cause evaluation to fail.
    For example, R"(\u03B1)" is an invalid identifier and is not interpreted as "α".
    — end note]
  • if options.name does not contain a value, then options.bit_width contains a value;
  • if options.bit_width contains a value V, then
    • is_integral_type(type) || is_enumeration_type(type) is true,
    • options.alignment does not contain a value,
    • options.no_unique_address is false, and
    • if V equals 0, then options.name does not contain a value; and
  • if options.alignment contains a value, it is an alignment value ([basic.align]) not less than alignment_of(type).
Returns: A reflection of a data member description ([class.mem.general]) where
  • T is the type represented by dealias(type),
  • N is either the identifier encoded by options.name or ⊥ if options.name does not contain a value,
  • A is either the alignment value held by options.alignment or ⊥ if options.alignment does not contain a value,
  • W is either the value held by options.bit_width or ⊥ if options.bit_width does not contain a value, and
  • NUA is the value held by options.no_unique_address.
[Note 3: 
The returned reflection value is primarily useful in conjunction with define_aggregate; it can also be queried by certain other functions in std​::​meta (e.g., type_of, identifier_of).
— end note]
consteval bool is_data_member_spec(info r);
Returns: true if r represents a data member description.
Otherwise, false.
template<reflection_range R = initializer_list<info>> consteval info define_aggregate(info class_type, R&& mdescrs);
Let C be the class represented by class_type and be the reflection value in mdescrs.
For every in mdescrs, let be the corresponding data member description represented by .
Constant When:
  • C is incomplete from every point in the evaluation context;
    [Note 4: 
    C can be a class template specialization for which there is a reachable definition of the class template.
    In this case, the injected declaration is an explicit specialization.
    — end note]
  • is_data_member_spec() is true for every ;
  • is_complete_type() is true for every ; and
  • for every pair where , if is not ⊥ and is not ⊥, then either:
    • != is true or
    • != u8"_" is true.
      [Note 5: 
      C can be a class template specialization for which there is a reachable definition of the class template.
      In this case, the injected declaration is an explicit specialization.
      — end note]
Effects: Produces an injected declaration C ([expr.const]) that defines C and has properties as follows:
  • The target scope of D is the scope to which C belongs ([basic.scope.scope]).
  • The locus of D follows immediately after the core constant expression currently under evaluation.
  • The characteristic sequence of D ([expr.const]) is the sequence of reflection values .
  • If C is a specialization of a templated class T, and C is not a local class, then D is an explicit specialization of T.
  • For each , there is a corresponding entity belonging to the class cope of D with the following properties:
    • If is ⊥, is an unnamed bit-field.
      Otherwise, is a non-static data member whose name is the identifier determined by the character seqeunce encoed by in UTF-8.
    • The type of is .
    • is declared with the attribute [[no_unique_address]] if and only if is true.
    • If is not ⊥, is a bit-field whose width is that value.
      Otherwise, is not a bit-field.
    • If is not ⊥, has the alignment-specifier alignas().
      Otherwise, has no alignment-specifier.
  • For every in mdescrs such that , the declaration corresponding to precedes the declaration corresponding to .
Returns: class_type.

21.4.16 Reflection type traits [meta.reflection.traits]

This subclause specifies consteval functions to query the properties of types ([meta.unary]), query the relationships between types ([meta.rel]), or transform types ([meta.trans]), during program translation.
Each consteval function declared in this class has an associated class template declared elsewhere in this document.
Every function and function template declared in this subclause has the following conditions required for a call to that function or function template to be a constant subexpression ([defns.const.subexpr]):
  • For every parameter p of type info, is_type(p) is true.
  • For every parameter r whose type is constrained on reflection_range, ranges​::​​all_of(​r, is_type) is true.
// associated with [meta.unary.cat], primary type categories consteval bool is_void_type(info type); consteval bool is_null_pointer_type(info type); consteval bool is_integral_type(info type); consteval bool is_floating_point_type(info type); consteval bool is_array_type(info type); consteval bool is_pointer_type(info type); consteval bool is_lvalue_reference_type(info type); consteval bool is_rvalue_reference_type(info type); consteval bool is_member_object_pointer_type(info type); consteval bool is_member_function_pointer_type(info type); consteval bool is_enum_type(info type); consteval bool is_union_type(info type); consteval bool is_class_type(info type); consteval bool is_function_type(info type); consteval bool is_reflection_type(info type); // associated with [meta.unary.comp], composite type categories consteval bool is_reference_type(info type); consteval bool is_arithmetic_type(info type); consteval bool is_fundamental_type(info type); consteval bool is_object_type(info type); consteval bool is_scalar_type(info type); consteval bool is_compound_type(info type); consteval bool is_member_pointer_type(info type); // associated with [meta.unary.prop], type properties consteval bool is_const_type(info type); consteval bool is_volatile_type(info type); consteval bool is_trivially_copyable_type(info type); consteval bool is_trivially_relocatable_type(info type); consteval bool is_replaceable_type(info type); consteval bool is_standard_layout_type(info type); consteval bool is_empty_type(info type); consteval bool is_polymorphic_type(info type); consteval bool is_abstract_type(info type); consteval bool is_final_type(info type); consteval bool is_aggregate_type(info type); consteval bool is_consteval_only_type(info type); consteval bool is_signed_type(info type); consteval bool is_unsigned_type(info type); consteval bool is_bounded_array_type(info type); consteval bool is_unbounded_array_type(info type); consteval bool is_scoped_enum_type(info type); template<reflection_range R = initializer_list<info>> consteval bool is_constructible_type(info type, R&& type_args); consteval bool is_default_constructible_type(info type); consteval bool is_copy_constructible_type(info type); consteval bool is_move_constructible_type(info type); consteval bool is_assignable_type(info type_dst, info type_src); consteval bool is_copy_assignable_type(info type); consteval bool is_move_assignable_type(info type); consteval bool is_swappable_with_type(info type_dst, info type_src); consteval bool is_swappable_type(info type); consteval bool is_destructible_type(info type); template<reflection_range R = initializer_list<info>> consteval bool is_trivially_constructible_type(info type, R&& type_args); consteval bool is_trivially_default_constructible_type(info type); consteval bool is_trivially_copy_constructible_type(info type); consteval bool is_trivially_move_constructible_type(info type); consteval bool is_trivially_assignable_type(info type_dst, info type_src); consteval bool is_trivially_copy_assignable_type(info type); consteval bool is_trivially_move_assignable_type(info type); consteval bool is_trivially_destructible_type(info type); template<reflection_range R = initializer_list<info>> consteval bool is_nothrow_constructible_type(info type, R&& type_args); consteval bool is_nothrow_default_constructible_type(info type); consteval bool is_nothrow_copy_constructible_type(info type); consteval bool is_nothrow_move_constructible_type(info type); consteval bool is_nothrow_assignable_type(info type_dst, info type_src); consteval bool is_nothrow_copy_assignable_type(info type); consteval bool is_nothrow_move_assignable_type(info type); consteval bool is_nothrow_swappable_with_type(info type_dst, info type_src); consteval bool is_nothrow_swappable_type(info type); consteval bool is_nothrow_destructible_type(info type); consteval bool is_nothrow_relocatable_type(info type); consteval bool is_implicit_lifetime_type(info type); consteval bool has_virtual_destructor(info type); consteval bool has_unique_object_representations(info type); consteval bool reference_constructs_from_temporary(info type_dst, info type_src); consteval bool reference_converts_from_temporary(info type_dst, info type_src); // associated with [meta.rel], type relations consteval bool is_same_type(info type1, info type2); consteval bool is_base_of_type(info type_base, info type_derived); consteval bool is_virtual_base_of_type(info type_base, info type_derived); consteval bool is_convertible_type(info type_src, info type_dst); consteval bool is_nothrow_convertible_type(info type_src, info type_dst); consteval bool is_layout_compatible_type(info type1, info type2); consteval bool is_pointer_interconvertible_base_of_type(info type_base, info type_derived); template<reflection_range R = initializer_list<info>> consteval bool is_invocable_type(info type, R&& type_args); template<reflection_range R = initializer_list<info>> consteval bool is_invocable_r_type(info type_result, info type, R&& type_args); template<reflection_range R = initializer_list<info>> consteval bool is_nothrow_invocable_type(info type, R&& type_args); template<reflection_range R = initializer_list<info>> consteval bool is_nothrow_invocable_r_type(info type_result, info type, R&& type_args); // associated with [meta.trans.cv], const-volatile modifications consteval info remove_const(info type); consteval info remove_volatile(info type); consteval info remove_cv(info type); consteval info add_const(info type); consteval info add_volatile(info type); consteval info add_cv(info type); // associated with [meta.trans.ref], reference modifications consteval info remove_reference(info type); consteval info add_lvalue_reference(info type); consteval info add_rvalue_reference(info type); // associated with [meta.trans.sign], sign modifications consteval info make_signed(info type); consteval info make_unsigned(info type); // associated with [meta.trans.arr], array modifications consteval info remove_extent(info type); consteval info remove_all_extents(info type); // associated with [meta.trans.ptr], pointer modifications consteval info remove_pointer(info type); consteval info add_pointer(info type); // associated with [meta.trans.other], other transformations consteval info remove_cvref(info type); consteval info decay(info type); template<reflection_range R = initializer_list<info>> consteval info common_type(R&& type_args); template<reflection_range R = initializer_list<info>> consteval info common_reference(R&& type_args); consteval info underlying_type(info type); template<reflection_range R = initializer_list<info>> consteval info invoke_result(info type, R&& type_args); consteval info unwrap_reference(info type); consteval info unwrap_ref_decay(info type);
Ech function or function template declared above has the following behavior based on the signature and return type of that function or function template.
[Note 1: 
The associated class template need not be instantiated.
— end note]
Table 64 — Reflection type traits [tab:meta.reflection.traits]
Signature and Return Type
Returns
bool meta​::​UNARY(info type);
bool meta​::​UNARY_type(info type);
std​::​UNARY_v<T>, where T is the type or type alias represented by type
bool meta​::​BINARY(info type);
bool meta​::​BINARY_type(info type);
std​::​BINARY_v<T1, T2>, where T1 and T2 are the types or type aliases represented by t1 and t2, respectively
template<reflection_range R>
bool meta​::​VARIADIC_type(info type, R&& args);
std​::​VARIADIC_v<T, U...>, where T is the type or type alias represented by type and U... is the pack of types or type aliases whose elements are represented by the corresponding elements of args
template<reflection_range R>
bool meta​::​VARIADIC_type(info t1, info t2, R&& args);
std​::​VARIADIC_v<T1, T2, U...>, where T1 and T2 are the types or type aliases represented by t1 and t2, respectively, and U... is the pack of types or type aliases whose elements are represented by the corresponding elements of args
info meta​::​UNARY(info type);
info meta​::​UNARY(info type);
A reflection representing the type denoted by std​::​UNARY_t<T>, where T is the type or type alias represented by type
template<reflection_range R>
info meta​::​VARIADIC(R&& args);
A reflection representing the type denoted by std​::​VARIADIC_t<T...>, where T... is the pack of types or type aliases whose elements are represented by the corresponding elements of args
template<reflection_range R>
info meta​::​VARIADIC(info type, R&& args);
A reflection representing the type denoted by std​::​VARIADIC_t<T, U...>, where T is the type or type alias represented by type and U... is the pack of types or type aliases whose elements are represented by the corresponding elements of args
[Note 2: 
For those functions or function templates which return a reflection, that reflection always represents a type and never a type alias.
— end note]
[Note 3: 
If t is a reflection of the type int and u is a reflection of an alias to the type int, then t == u is false but is_same_type(t, u) is true.
Also, t == dealias(u) is true.
— end note]
consteval size_t rank(info type);
Returns: rank_v<T>, where T is the type represented by dealias(type).
consteval size_t extent(info type, unsigned i = 0);
Returns: extent_v<T, I>, where T is the type represented by dealias(type) and I is a constant equal to i.
consteval size_t tuple_size(info type);
Returns: tuple_size_v<T>, where T is the type represented by dealias(type).
consteval info tuple_element(size_t index, info type);
Returns: A reflection representing the type denoted by tuple_element_t<I, T>, where T is th type represented by dealias(type), and I is a constant equal to index.
consteval size_t variant_size(info type);
Returns: variant_size_v<T>, where T is the type represented by dealias(type).
consteval info variant_alternative(size_t index, info type);
Returns: A reflection representing the type denoted by variant_alternative_t<I, T>, where T is the type represented by dealias(type) and I is a consant equal to index.
consteval strong_ordering type_order(info t1, info t2);
Returns: type_order_v<T1, T2>, where T1 and T2 are the types represented by dealias(t1) and dealias(t2), respectively.

21.4.17 Annotation reflection [meta.reflection.annotation]

consteval vector<info> annotations_of(info item);
Constant When: item represents a type, type alias, variable, function, namespace, enumerator, direct base class relationship, or non-static data member.
Let E be
  • the corresponding base-specifier if item represents a direct base class relationship,
  • otherwise, the entity represented by item.
Returns: A vector containing all of the reflections R representing each annotation applying to each declaration of E that precedes either some point in the evaluation context ([expr.const]) or a point immediately following the class-specifier of the outermost class for which such a point is in a complete-class context.
For any two reflections and in the returned vector, if the annotation represented by precedes the annotation represented by , then appears before .
If and represent annotations from the same translation unit T, any element in the returned vector between and represents an annotation from T.
[Note 1: 
The order in which two annotations appear is otherwise unspecified.
— end note]
[Example 1: [[=1]] void f(); [[=2, =3]] void g(); void g [[=4]] (); static_assert(annotations_of(^^f).size() == 1); static_assert(annotations_of(^^g).size() == 3); static_assert([: constant_of(annotations_of(^^g)[0]) :] == 2); static_assert(extract<int>(annotations_of(^^g)[1]) == 3); static_assert(extract<int>(annotations_of(^^g)[2]) == 4); struct Option { bool value; }; struct C { [[=Option{true}]] int a; [[=Option{false}]] int b; }; static_assert(extract<Option>(annotations_of(^^C::a)[0]).value); static_assert(!extract<Option>(annotations_of(^^C::b)[0]).value); template<class T> struct [[=42]] D { }; constexpr std::meta::info a1 = annotations_of(^^D<int>)[0]; constexpr std::meta::info a2 = annotations_of(^^D<char>)[0]; static_assert(a1 != a2); static_assert(constant_of(a1) == constant_of(a2)); [[=1]] int x, y; static_assert(annotations_of(^^x)[0] == annotations_of(^^y)[0]); — end example]
consteval vector<info> annotations_of_with_type(info item, info type);
Constant When:
  • annotations_of(item) is a constant expression and
  • dealias(type) represents a type that is complete from some point in the evaluation context.
Returns: A vector containing each element e of annotations_of(item) where remove_const(type_of(e)) == remove_const(type) is true, preserving their order.