diff --git a/2996_reflection/p2996r2.html b/2996_reflection/p2996r2.html index 06003976..343adf3c 100644 --- a/2996_reflection/p2996r2.html +++ b/2996_reflection/p2996r2.html @@ -631,19 +631,23 @@

Contents

  • 5.2.1 Header <meta> synopsis
  • 5.2.2 [meta.reflection.names] Reflection names and locations
  • 5.2.3 [meta.reflection.queries] Reflection queries
  • -
  • 5.2.4 [meta.reflection.unary] Unary type traits +
  • 5.2.4 [meta.reflection.member.queries], Reflection member queries
  • +
  • 5.2.5 [meta.reflection.unary] Unary type traits
  • +
  • 5.2.6 [meta.reflection.rel], Type relations
  • +
  • 5.2.7 [meta.reflection.trans], Transformatinos between types +
  • @@ -2010,149 +2014,159 @@

    consteval info template_of(info r); consteval vector<info> template_arguments_of(info r); - // [meta.reflection.unary.cat], primary type categories - consteval bool is_void(info type); - consteval bool is_null_pointer(info type); - consteval bool is_integral(info type); - consteval bool is_floating_point(info type); - consteval bool is_array(info type); - consteval bool is_pointer(info type); - consteval bool is_lvalue_reference(info type); - consteval bool is_rvalue_reference(info type); - consteval bool is_member_object_pointer(info type); - consteval bool is_member_function_pointer(info type); - consteval bool is_enum(info type); - consteval bool is_union(info type); - consteval bool is_class(info type); - consteval bool is_function(info type); - - // [meta.reflection.unary.comp], composite type categories - consteval bool is_reference(info type); - consteval bool is_arithmetic(info type); - consteval bool is_fundamental(info type); - consteval bool is_object(info type); - consteval bool is_scalar(info type); - consteval bool is_compound(info type); - consteval bool is_member_pointer(info type); - - // [meta.reflection unary.prop], type properties - consteval bool is_const(info type); - consteval bool is_volatile(info type); - consteval bool is_trivial(info type); - consteval bool is_trivially_copyable(info type); - consteval bool is_standard_layout(info type); - consteval bool is_empty(info type); - consteval bool is_polymorphic(info type); - consteval bool is_abstract(info type); - consteval bool is_final(info type); - consteval bool is_aggregate(info type); - consteval bool is_signed(info type); - consteval bool is_unsigned(info type); - consteval bool is_bounded_array(info type); - consteval bool is_unbounded_array(info type); - consteval bool is_scoped_enum(info type); - - consteval bool is_constructible(info type, span<info const> type_args); - consteval bool is_default_constructible(info type); - consteval bool is_copy_constructible(info type); - consteval bool is_move_constructible(info type); - - consteval bool is_assignable(info dst_type, info src_type); - consteval bool is_copy_assignable(info type); - consteval bool is_move_assignable(info type); - - consteval bool is_swappable_with(info dst_type, info src_type); - consteval bool is_swappable(info type); - - consteval bool is_destructible(info type); - - consteval bool is_trivially_constructible(info type, span<info const> type_args); - consteval bool is_trivially_default_constructible(info type); - consteval bool is_trivially_copy_constructible(info type); - consteval bool is_trivially_move_constructible(info type); + // [meta.reflection.member.queries], reflection member queries + template<class... Fs> + consteval vector<info> members_of(info r, Fs... filters); + template<class... Fs> + consteval vector<info> bases_of(info class_type, Fs... filters); + consteval vector<info> static_data_members_of(info class_type); + consteval vector<info> nonstatic_data_members_of(info class_type); + consteval vector<info> subobjects_of(info class_type); + consteval vector<info> enumerators_of(info enum_type); + + // [meta.reflection.unary.cat], primary type categories + consteval bool is_void(info type); + consteval bool is_null_pointer(info type); + consteval bool is_integral(info type); + consteval bool is_floating_point(info type); + consteval bool is_array(info type); + consteval bool is_pointer(info type); + consteval bool is_lvalue_reference(info type); + consteval bool is_rvalue_reference(info type); + consteval bool is_member_object_pointer(info type); + consteval bool is_member_function_pointer(info type); + consteval bool is_enum(info type); + consteval bool is_union(info type); + consteval bool is_class(info type); + consteval bool is_function(info type); + + // [meta.reflection.unary.comp], composite type categories + consteval bool is_reference(info type); + consteval bool is_arithmetic(info type); + consteval bool is_fundamental(info type); + consteval bool is_object(info type); + consteval bool is_scalar(info type); + consteval bool is_compound(info type); + consteval bool is_member_pointer(info type); + + // [meta.reflection unary.prop], type properties + consteval bool is_const(info type); + consteval bool is_volatile(info type); + consteval bool is_trivial(info type); + consteval bool is_trivially_copyable(info type); + consteval bool is_standard_layout(info type); + consteval bool is_empty(info type); + consteval bool is_polymorphic(info type); + consteval bool is_abstract(info type); + consteval bool is_final(info type); + consteval bool is_aggregate(info type); + consteval bool is_signed(info type); + consteval bool is_unsigned(info type); + consteval bool is_bounded_array(info type); + consteval bool is_unbounded_array(info type); + consteval bool is_scoped_enum(info type); + + consteval bool is_constructible(info type, span<info const> type_args); + consteval bool is_default_constructible(info type); + consteval bool is_copy_constructible(info type); + consteval bool is_move_constructible(info type); + + consteval bool is_assignable(info dst_type, info src_type); + consteval bool is_copy_assignable(info type); + consteval bool is_move_assignable(info type); - consteval bool is_trivially_assignable(info dst_type, info src_type); - consteval bool is_trivially_copy_assignable(info type); - consteval bool is_trivially_move_assignable(info type); - consteval bool is_trivially_destructible(info type); + consteval bool is_swappable_with(info dst_type, info src_type); + consteval bool is_swappable(info type); + + consteval bool is_destructible(info type); - consteval bool is_nothrow_constructible(info type, span<info const> type_args); - consteval bool is_nothrow_default_constructible(info type); - consteval bool is_nothrow_copy_constructible(info type); - consteval bool is_nothrow_move_constructible(info type); + consteval bool is_trivially_constructible(info type, span<info const> type_args); + consteval bool is_trivially_default_constructible(info type); + consteval bool is_trivially_copy_constructible(info type); + consteval bool is_trivially_move_constructible(info type); - consteval bool is_nothrow_assignable(info dst_type, info src_type); - consteval bool is_nothrow_copy_assignable(info type); - consteval bool is_nothrow_move_assignable(info type); - - consteval bool is_nothrow_swappable_with(info dst_type, info src_type); - consteval bool is_nothrow_swappable(info type); - - consteval bool is_nothrow_destructible(info type); - - consteval bool is_implicit_lifetime(info type); - - consteval bool has_virtual_destructor(info type); - - consteval bool has_unique_object_representations(info type); - - consteval bool reference_constructs_from_temporary(info dst_type, info src_type); - consteval bool reference_converts_from_temporary(info dst_type, info src_type); - - // [meta.reflection.unary.prop.query], type property queries - consteval size_t alignment_of(info type); - consteval size_t rank(info type); - consteval size_t extent(info type, unsigned i = 0); + consteval bool is_trivially_assignable(info dst_type, info src_type); + consteval bool is_trivially_copy_assignable(info type); + consteval bool is_trivially_move_assignable(info type); + consteval bool is_trivially_destructible(info type); + + consteval bool is_nothrow_constructible(info type, span<info const> type_args); + consteval bool is_nothrow_default_constructible(info type); + consteval bool is_nothrow_copy_constructible(info type); + consteval bool is_nothrow_move_constructible(info type); + + consteval bool is_nothrow_assignable(info dst_type, info src_type); + consteval bool is_nothrow_copy_assignable(info type); + consteval bool is_nothrow_move_assignable(info type); + + consteval bool is_nothrow_swappable_with(info dst_type, info src_type); + consteval bool is_nothrow_swappable(info type); + + consteval bool is_nothrow_destructible(info type); + + consteval bool is_implicit_lifetime(info type); + + consteval bool has_virtual_destructor(info type); - // [meta.reflection.rel], type relations - consteval bool is_same(info type1, info type2); - consteval bool is_base_of(info base_type, info derived_type); - consteval bool is_convertible(info src_type, info dst_type); - consteval bool is_nothrow_convertible(info src_type, info dst_type); - consteval bool is_layout_compatible(info type1, info type2); - consteval bool is_pointer_interconvertible_base_of(info base_type, info derived_type); - - consteval bool is_invocable(info type, span<const info> type_args); - consteval bool is_invocable_r(info result_type, info type, span<const info> type_args); - - consteval bool is_nothrow_invocable(info type, span<const info> type_args); - consteval bool is_nothrow_invocable_r(info result_type, info type, span<const info> type_args); - - // [meta.reflection.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); - - // [meta.reflection.trans.ref], reference modifications - consteval info remove_reference(info type); - consteval info add_lvalue_reference(info type); - consteval info add_rvalue_reference(info type); - - // [meta.reflection.trans.sign], sign modifications - consteval info make_signed(info type); - consteval info make_unsigned(info type); - - // [meta.reflection.trans.arr], array modifications - consteval info remove_extent(info type); - consteval info remove_all_extents(info type); - - // [meta.reflection.trans.ptr], pointer modifications - consteval info remove_pointer(info type); - consteval info add_pointer(info type); - - // [meta.reflection.trans.other], other transformations - consteval info remove_cvref(info type); - consteval info decay(info type); - consteval info common_type(span<const info> type_args); - consteval info common_reference(span<const info> type_args); - consteval info underlying_type(info type); - consteval info invoke_result(info type, span<const info> type_args); - consteval info unwrap_reference(info type); - consteval info unwrap_ref_decay(info type); -} + consteval bool has_unique_object_representations(info type); + + consteval bool reference_constructs_from_temporary(info dst_type, info src_type); + consteval bool reference_converts_from_temporary(info dst_type, info src_type); + + // [meta.reflection.unary.prop.query], type property queries + consteval size_t alignment_of(info type); + consteval size_t rank(info type); + consteval size_t extent(info type, unsigned i = 0); + + // [meta.reflection.rel], type relations + consteval bool is_same(info type1, info type2); + consteval bool is_base_of(info base_type, info derived_type); + consteval bool is_convertible(info src_type, info dst_type); + consteval bool is_nothrow_convertible(info src_type, info dst_type); + consteval bool is_layout_compatible(info type1, info type2); + consteval bool is_pointer_interconvertible_base_of(info base_type, info derived_type); + + consteval bool is_invocable(info type, span<const info> type_args); + consteval bool is_invocable_r(info result_type, info type, span<const info> type_args); + + consteval bool is_nothrow_invocable(info type, span<const info> type_args); + consteval bool is_nothrow_invocable_r(info result_type, info type, span<const info> type_args); + + // [meta.reflection.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); + + // [meta.reflection.trans.ref], reference modifications + consteval info remove_reference(info type); + consteval info add_lvalue_reference(info type); + consteval info add_rvalue_reference(info type); + + // [meta.reflection.trans.sign], sign modifications + consteval info make_signed(info type); + consteval info make_unsigned(info type); + + // [meta.reflection.trans.arr], array modifications + consteval info remove_extent(info type); + consteval info remove_all_extents(info type); + + // [meta.reflection.trans.ptr], pointer modifications + consteval info remove_pointer(info type); + consteval info add_pointer(info type); + + // [meta.reflection.trans.other], other transformations + consteval info remove_cvref(info type); + consteval info decay(info type); + consteval info common_type(span<const info> type_args); + consteval info common_reference(span<const info> type_args); + consteval info underlying_type(info type); + consteval info invoke_result(info type, span<const info> type_args); + consteval info unwrap_reference(info type); + consteval info unwrap_ref_decay(info type); +}

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

    @@ -2257,224 +2271,256 @@

    -end example]

    -

    5.2.4 [meta.reflection.unary] Unary type traits

    +

    5.2.4 [meta.reflection.member.queries], Reflection member queries

    +
    +
    +
    template<class... Fs>
    +  consteval vector<info> members_of(info r, Fs... filters);
    +

    1 Mandates: r is a reflection designating either a class type or a namespace and (std::predicate<Fs, info> && ...) is true.

    +

    2 Returns: A vector containing the reflections of all the members m of the entity designated by r such that (filters(m) && ...) is true, in the order in which they are declared. Note 1: Base classes precede any members and are returned in the order they are listed in the base-specifier-list. — end note ]

    +
    template<class... Fs>
    +  consteval vector<info> bases_of(info class_type, Fs... filters);
    +

    3 Mandates: class_type designates a class type.

    +

    4 Effects: Equivalent to return members_of(class_type, is_base, filters...);

    +
    consteval vector<info> static_data_members_of(info class_type);
    +

    5 Mandates: class_type designates a class type.

    +

    6 Effects: Equivalent to return members_of(class_type, is_variable);

    +
    consteval vector<info> nonstatic_data_members_of(info class_type);
    +

    7 Mandates: class_type designates a class type.

    +

    8 Effects: Equivalent to return members_of(class_type, is_nsdm);

    +
    consteval vector<info> subobjects_of(info class_type);
    +

    9 Mandates: class_type designates a class type.

    +

    10 Returns: A vector containing all the reflections in bases_of(class_type) followed by all the reflections in nonstatic_data_members_of(class_type).

    +
    consteval vector<info> enumerators_of(info enum_type);
    +

    11 Mandates: enum_type designates an enumeration.

    +

    12 Returns: A vector containing the reflections of each enumerator of the enumeration designated by enum_type.

    +
    +
    +

    5.2.5 [meta.reflection.unary] Unary type traits

    -

    1 Subclause [meta.reflection.unary] contains consteval functions that may be used to query the properties of a type at compile time.

    -

    2 For each function taking an argument of type meta::info whose name contains type, that argument shall be a reflection of a type or type-alias. For each function taking an argument of type span<const meta::info> named type_args, each meta::info in that span shall be a reflection of a type or a type-alias.

    +

    1 Subclause [meta.reflection.unary] contains consteval functions that may be used to query the properties of a type at compile time.

    +

    2 For each function taking an argument of type meta::info whose name contains type, that argument shall be a reflection of a type or type-alias. For each function taking an argument of type span<const meta::info> named type_args, each meta::info in that span shall be a reflection of a type or a type-alias.

    -

    5.2.4.1 [meta.reflection.unary.cat] Primary type categories

    +

    5.2.5.1 [meta.reflection.unary.cat] Primary type categories

    -

    1 For any type T, for each function std::meta::TRAIT defined in this clause, std::meta::TRAIT(^T) equals the value of the corresponding unary type trait std::TRAIT_v<T> as specified in 21.3.5.2 [meta.unary.cat].

    -
    consteval bool is_void(info type);
    -consteval bool is_null_pointer(info type);
    -consteval bool is_integral(info type);
    -consteval bool is_floating_point(info type);
    -consteval bool is_array(info type);
    -consteval bool is_pointer(info type);
    -consteval bool is_lvalue_reference(info type);
    -consteval bool is_rvalue_reference(info type);
    -consteval bool is_member_object_pointer(info type);
    -consteval bool is_member_function_pointer(info type);
    -consteval bool is_enum(info type);
    -consteval bool is_union(info type);
    -consteval bool is_class(info type);
    -consteval bool is_function(info type);
    -

    2 [Example

    -
    // an example implementation
    -namespace std::meta {
    -  consteval bool is_void(info type) {
    -    return value_of<bool>(substitute(^is_void_v, {type}));
    -  }
    -}
    +

    1 For any type T, for each function std::meta::TRAIT defined in this clause, std::meta::TRAIT(^T) equals the value of the corresponding unary type trait std::TRAIT_v<T> as specified in 21.3.5.2 [meta.unary.cat].

    +
    consteval bool is_void(info type);
    +consteval bool is_null_pointer(info type);
    +consteval bool is_integral(info type);
    +consteval bool is_floating_point(info type);
    +consteval bool is_array(info type);
    +consteval bool is_pointer(info type);
    +consteval bool is_lvalue_reference(info type);
    +consteval bool is_rvalue_reference(info type);
    +consteval bool is_member_object_pointer(info type);
    +consteval bool is_member_function_pointer(info type);
    +consteval bool is_enum(info type);
    +consteval bool is_union(info type);
    +consteval bool is_class(info type);
    +consteval bool is_function(info type);
    +

    2 [Example

    +
    // an example implementation
    +namespace std::meta {
    +  consteval bool is_void(info type) {
    +    return value_of<bool>(substitute(^is_void_v, {type}));
    +  }
    +}

    -end example]

    -

    5.2.4.2 [meta.reflection.unary.comp] Composite type categories

    +

    5.2.5.2 [meta.reflection.unary.comp] Composite type categories

    +
    +
    +

    1 For any type T, for each function std::meta::TRAIT defined in this clause, std::meta::TRAIT(^T) equals the value of the corresponding unary type trait std::TRAIT_v<T> as specified in 21.3.5.3 [meta.unary.comp].

    +
    consteval bool is_reference(info type);
    +consteval bool is_arithmetic(info type);
    +consteval bool is_fundamental(info type);
    +consteval bool is_object(info type);
    +consteval bool is_scalar(info type);
    +consteval bool is_compound(info type);
    +consteval bool is_member_pointer(info type);
    +
    +
    +

    5.2.5.3 [meta.reflection.unary.prop] Type properties

    -

    1 For any type T, for each function std::meta::TRAIT defined in this clause, std::meta::TRAIT(^T) equals the value of the corresponding unary type trait std::TRAIT_v<T> as specified in 21.3.5.3 [meta.unary.comp].

    -
    consteval bool is_reference(info type);
    -consteval bool is_arithmetic(info type);
    -consteval bool is_fundamental(info type);
    -consteval bool is_object(info type);
    -consteval bool is_scalar(info type);
    -consteval bool is_compound(info type);
    -consteval bool is_member_pointer(info type);
    +

    1 For any type T, for each function std::meta::UNARY-TRAIT defined in this clause with signature bool(std::meta::info), std::meta::UNARY-TRAIT(^T) equals the value of the corresponding type property std::UNARY-TRAIT_v<T> as specified in 21.3.5.4 [meta.unary.prop].

    +

    2 For any types T and U, for each function std::meta::BINARY-TRAIT defined in this clause with signature bool(std::meta::info, std::meta::info), std::meta::BINARY-TRAIT(^T, ^U) equals the value of the corresponding type property std::BINARY-TRAIT_v<T, U> as specified in 21.3.5.4 [meta.unary.prop].

    +

    3 For any type T and pack of types U..., for each function std::meta::VARIADIC-TRAIT defined in this clause with signature bool(std::meta::info, std::span<const std::meta::info>), std::meta::VARIADIC-TRAIT(^T, {^U...}) equals the value of the corresponding type property std::VARIADIC-TRAIT_v<T, U...> as specified in 21.3.5.4 [meta.unary.prop].

    +
    consteval bool is_const(info type);
    +consteval bool is_volatile(info type);
    +consteval bool is_trivial(info type);
    +consteval bool is_trivially_copyable(info type);
    +consteval bool is_standard_layout(info type);
    +consteval bool is_empty(info type);
    +consteval bool is_polymorphic(info type);
    +consteval bool is_abstract(info type);
    +consteval bool is_final(info type);
    +consteval bool is_aggregate(info type);
    +consteval bool is_signed(info type);
    +consteval bool is_unsigned(info type);
    +consteval bool is_bounded_array(info type);
    +consteval bool is_unbounded_array(info type);
    +consteval bool is_scoped_enum(info type);
    +
    +consteval bool is_constructible(info type, span<info const> type_args);
    +consteval bool is_default_constructible(info type);
    +consteval bool is_copy_constructible(info type);
    +consteval bool is_move_constructible(info type);
    +
    +consteval bool is_assignable(info dst_type, info src_type);
    +consteval bool is_copy_assignable(info type);
    +consteval bool is_move_assignable(info type);
    +
    +consteval bool is_swappable_with(info dst_type, info src_type);
    +consteval bool is_swappable(info type);
    +
    +consteval bool is_destructible(info type);
    +
    +consteval bool is_trivially_constructible(info type, span<info const> type_args);
    +consteval bool is_trivially_default_constructible(info type);
    +consteval bool is_trivially_copy_constructible(info type);
    +consteval bool is_trivially_move_constructible(info type);
    +
    +consteval bool is_trivially_assignable(info dst_type, info src_type);
    +consteval bool is_trivially_copy_assignable(info type);
    +consteval bool is_trivially_move_assignable(info type);
    +consteval bool is_trivially_destructible(info type);
    +
    +consteval bool is_nothrow_constructible(info type, span<info const> type_args);
    +consteval bool is_nothrow_default_constructible(info type);
    +consteval bool is_nothrow_copy_constructible(info type);
    +consteval bool is_nothrow_move_constructible(info type);
    +
    +consteval bool is_nothrow_assignable(info dst_type, info src_type);
    +consteval bool is_nothrow_copy_assignable(info type);
    +consteval bool is_nothrow_move_assignable(info type);
    +
    +consteval bool is_nothrow_swappable_with(info dst_type, info src_type);
    +consteval bool is_nothrow_swappable(info type);
    +
    +consteval bool is_nothrow_destructible(info type);
    +
    +consteval bool is_implicit_lifetime(info type);
    +
    +consteval bool has_virtual_destructor(info type);
    +
    +consteval bool has_unique_object_representations(info type);
    +
    +consteval bool reference_constructs_from_temporary(info dst_type, info src_type);
    +consteval bool reference_converts_from_temporary(info dst_type, info src_type);
    -

    5.2.4.3 [meta.reflection.unary.prop] Type properties

    +

    5.2.5.4 [meta.reflection.unary.prop.query] Type property queries

    -

    1 For any type T, for each function std::meta::UNARY-TRAIT defined in this clause with signature bool(std::meta::info), std::meta::UNARY-TRAIT(^T) equals the value of the corresponding type property std::UNARY-TRAIT_v<T> as specified in 21.3.5.4 [meta.unary.prop].

    -

    2 For any types T and U, for each function std::meta::BINARY-TRAIT defined in this clause with signature bool(std::meta::info, std::meta::info), std::meta::BINARY-TRAIT(^T, ^U) equals the value of the corresponding type property std::BINARY-TRAIT_v<T, U> as specified in 21.3.5.4 [meta.unary.prop].

    -

    3 For any type T and pack of types U..., for each function std::meta::VARIADIC-TRAIT defined in this clause with signature bool(std::meta::info, std::span<const std::meta::info>), std::meta::VARIADIC-TRAIT(^T, {^U...}) equals the value of the corresponding type property std::VARIADIC-TRAIT_v<T, U...> as specified in 21.3.5.4 [meta.unary.prop].

    -
    consteval bool is_const(info type);
    -consteval bool is_volatile(info type);
    -consteval bool is_trivial(info type);
    -consteval bool is_trivially_copyable(info type);
    -consteval bool is_standard_layout(info type);
    -consteval bool is_empty(info type);
    -consteval bool is_polymorphic(info type);
    -consteval bool is_abstract(info type);
    -consteval bool is_final(info type);
    -consteval bool is_aggregate(info type);
    -consteval bool is_signed(info type);
    -consteval bool is_unsigned(info type);
    -consteval bool is_bounded_array(info type);
    -consteval bool is_unbounded_array(info type);
    -consteval bool is_scoped_enum(info type);
    -
    -consteval bool is_constructible(info type, span<info const> type_args);
    -consteval bool is_default_constructible(info type);
    -consteval bool is_copy_constructible(info type);
    -consteval bool is_move_constructible(info type);
    -
    -consteval bool is_assignable(info dst_type, info src_type);
    -consteval bool is_copy_assignable(info type);
    -consteval bool is_move_assignable(info type);
    -
    -consteval bool is_swappable_with(info dst_type, info src_type);
    -consteval bool is_swappable(info type);
    -
    -consteval bool is_destructible(info type);
    -
    -consteval bool is_trivially_constructible(info type, span<info const> type_args);
    -consteval bool is_trivially_default_constructible(info type);
    -consteval bool is_trivially_copy_constructible(info type);
    -consteval bool is_trivially_move_constructible(info type);
    -
    -consteval bool is_trivially_assignable(info dst_type, info src_type);
    -consteval bool is_trivially_copy_assignable(info type);
    -consteval bool is_trivially_move_assignable(info type);
    -consteval bool is_trivially_destructible(info type);
    -
    -consteval bool is_nothrow_constructible(info type, span<info const> type_args);
    -consteval bool is_nothrow_default_constructible(info type);
    -consteval bool is_nothrow_copy_constructible(info type);
    -consteval bool is_nothrow_move_constructible(info type);
    -
    -consteval bool is_nothrow_assignable(info dst_type, info src_type);
    -consteval bool is_nothrow_copy_assignable(info type);
    -consteval bool is_nothrow_move_assignable(info type);
    -
    -consteval bool is_nothrow_swappable_with(info dst_type, info src_type);
    -consteval bool is_nothrow_swappable(info type);
    -
    -consteval bool is_nothrow_destructible(info type);
    -
    -consteval bool is_implicit_lifetime(info type);
    -
    -consteval bool has_virtual_destructor(info type);
    -
    -consteval bool has_unique_object_representations(info type);
    -
    -consteval bool reference_constructs_from_temporary(info dst_type, info src_type);
    -consteval bool reference_converts_from_temporary(info dst_type, info src_type);
    +

    1 For any type T, for each function std::meta::PROP defined in this clause with signature size_t(std::meta::info), std::meta::PROP(^T) equals the value of the corresponding type property std::PROP_v<T> as specified in 21.3.6 [meta.unary.prop.query].

    +

    2 For any type T and unsigned integer value I, std::meta::extent(^T, I) equals std::extent_v<T, I> ([meta.unary.prop.query]).

    +
    consteval size_t alignment_of(info type);
    +consteval size_t rank(info type);
    +consteval size_t extent(info type, unsigned i = 0);
    -

    5.2.4.4 [meta.reflection.unary.prop.query] Type property queries

    +

    5.2.6 [meta.reflection.rel], Type relations

    -

    1 For any type T, for each function std::meta::PROP defined in this clause with signature size_t(std::meta::info), std::meta::PROP(^T) equals the value of the corresponding type property std::PROP_v<T> as specified in 21.3.6 [meta.unary.prop.query].

    -

    2 For any type T and unsigned integer value I, std::meta::extent(^T, I) equals std::extent_v<T, I> ([meta.unary.prop.query]).

    -
    consteval size_t alignment_of(info type);
    -consteval size_t rank(info type);
    -consteval size_t extent(info type, unsigned i = 0);
    +

    1 The consteval functions specified in this clause may be used to query relationships between types at compile time.

    +

    2 For any types T and U, for each function std::meta::REL defined in this clause with signature bool(std::meta::info, std::meta::info), std::meta::REL(^T, ^U) equals the value of the corresponding type relation std::REL_v<T, U> as specified in 21.3.7 [meta.rel].

    +

    3 For any type T and pack of types U..., for each function std::meta::VARIADIC-REL defined in this clause with signature bool(std::meta::info, std::span<const std::meta::info>), std::meta::VARIADIC-REL(^T, {^U...}) equals the value of the corresponding type relation std::VARIADIC-REL_v<T, U...> as specified in 21.3.7 [meta.rel].

    +

    4 For any types T and R and pack of types U..., for each function std::meta::VARIADIC-REL-R defined in this clause with signature bool(std::meta::info, std::meta::info, std::span<const std::meta::info>), std::meta::VARIADIC-REL-R(^R, ^T, {^U...}) equals the value of the corresponding type relation std::VARIADIC-REL-R_v<R, T, U...> as specified in 21.3.7 [meta.rel].

    +
    consteval bool is_same(info type1, info type2);
    +consteval bool is_base_of(info base_type, info derived_type);
    +consteval bool is_convertible(info src_type, info dst_type);
    +consteval bool is_nothrow_convertible(info src_type, info dst_type);
    +consteval bool is_layout_compatible(info type1, info type2);
    +consteval bool is_pointer_interconvertible_base_of(info base_type, info derived_type);
    +
    +consteval bool is_invocable(info type, span<const info> type_args);
    +consteval bool is_invocable_r(info result_type, info type, span<const info> type_args);
    +
    +consteval bool is_nothrow_invocable(info type, span<const info> type_args);
    +consteval bool is_nothrow_invocable_r(info result_type, info type, span<const info> type_args);
    +

    5 Note 1: 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(t, u) is true. t == dealias(u) is also true. — end note ].

    -

    5.2.4.5 [meta.reflection.rel], Type relations

    +

    5.2.7 [meta.reflection.trans], Transformatinos between types

    -

    1 For any types T and U, for each function std::meta::REL defined in this clause with signature bool(std::meta::info, std::meta::info), std::meta::REL(^T, ^U) equals the value of the corresponding type relation std::REL_v<T, U> as specified in 21.3.7 [meta.rel].

    -

    2 For any type T and pack of types U..., for each function std::meta::VARIADIC-REL defined in this clause with signature bool(std::meta::info, std::span<const std::meta::info>), std::meta::VARIADIC-REL(^T, {^U...}) equals the value of the corresponding type relation std::VARIADIC-REL_v<T, U...> as specified in 21.3.7 [meta.rel].

    -

    3 For any types T and R and pack of types U..., for each function std::meta::VARIADIC-REL-R defined in this clause with signature bool(std::meta::info, std::meta::info, std::span<const std::meta::info>), std::meta::VARIADIC-REL-R(^R, ^T, {^U...}) equals the value of the corresponding type relation std::VARIADIC-REL-R_v<R, T, U...> as specified in 21.3.7 [meta.rel].

    -
    consteval bool is_same(info type1, info type2);
    -consteval bool is_base_of(info base_type, info derived_type);
    -consteval bool is_convertible(info src_type, info dst_type);
    -consteval bool is_nothrow_convertible(info src_type, info dst_type);
    -consteval bool is_layout_compatible(info type1, info type2);
    -consteval bool is_pointer_interconvertible_base_of(info base_type, info derived_type);
    -
    -consteval bool is_invocable(info type, span<const info> type_args);
    -consteval bool is_invocable_r(info result_type, info type, span<const info> type_args);
    -
    -consteval bool is_nothrow_invocable(info type, span<const info> type_args);
    -consteval bool is_nothrow_invocable_r(info result_type, info type, span<const info> type_args);
    -

    4 Note 1: 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(t, u) is true. t == dealias(u) is also true. — end note ].

    +

    1 Subclause [meta.reflection.trans] contains consteval functions that may be used to transform one type to another following some predefined rule.

    -

    5.2.4.6 [meta.reflection.trans.cv], Const-volatile modifications

    +

    5.2.7.1 [meta.reflection.trans.cv], Const-volatile modifications

    -

    1 For any type T, for each function std::meta::MOD defined in this clause, std::meta::MOD(^T) returns the reflection of the corresponding type std::MOD_t<T> as specified in 21.3.8.2 [meta.trans.cv].

    -
    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);
    +

    1 For any type T, for each function std::meta::MOD defined in this clause, std::meta::MOD(^T) returns the reflection of the corresponding type std::MOD_t<T> as specified in 21.3.8.2 [meta.trans.cv].

    +
    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);
    -

    5.2.4.7 [meta.reflection.trans.ref], Reference modifications

    +

    5.2.7.2 [meta.reflection.trans.ref], Reference modifications

    -

    1 For any type T, for each function std::meta::MOD defined in this clause, std::meta::MOD(^T) returns the reflection of the corresponding type std::MOD_t<T> as specified in 21.3.8.3 [meta.trans.ref].

    -
    consteval info remove_reference(info type);
    -consteval info add_lvalue_reference(info type);
    -consteval info add_rvalue_reference(info type);
    +

    1 For any type T, for each function std::meta::MOD defined in this clause, std::meta::MOD(^T) returns the reflection of the corresponding type std::MOD_t<T> as specified in 21.3.8.3 [meta.trans.ref].

    +
    consteval info remove_reference(info type);
    +consteval info add_lvalue_reference(info type);
    +consteval info add_rvalue_reference(info type);
    -

    5.2.4.8 [meta.reflection.trans.sign], Sign modifications

    +

    5.2.7.3 [meta.reflection.trans.sign], Sign modifications

    -

    1 For any type T, for each function std::meta::MOD defined in this clause, std::meta::MOD(^T) returns the reflection of the corresponding type std::MOD_t<T> as specified in 21.3.8.4 [meta.trans.sign].

    -
    consteval info make_signed(info type);
    -consteval info make_unsigned(info type);
    +

    1 For any type T, for each function std::meta::MOD defined in this clause, std::meta::MOD(^T) returns the reflection of the corresponding type std::MOD_t<T> as specified in 21.3.8.4 [meta.trans.sign].

    +
    consteval info make_signed(info type);
    +consteval info make_unsigned(info type);
    -

    5.2.4.9 [meta.reflection.trans.arr], Array modifications

    +

    5.2.7.4 [meta.reflection.trans.arr], Array modifications

    -

    1 For any type T, for each function std::meta::MOD defined in this clause, std::meta::MOD(^T) returns the reflection of the corresponding type std::MOD_t<T> as specified in 21.3.8.5 [meta.trans.arr].

    -
    consteval info remove_extent(info type);
    -consteval info remove_all_extents(info type);
    +

    1 For any type T, for each function std::meta::MOD defined in this clause, std::meta::MOD(^T) returns the reflection of the corresponding type std::MOD_t<T> as specified in 21.3.8.5 [meta.trans.arr].

    +
    consteval info remove_extent(info type);
    +consteval info remove_all_extents(info type);
    -

    5.2.4.10 [meta.reflection.trans.ptr], Pointer modifications

    +

    5.2.7.5 [meta.reflection.trans.ptr], Pointer modifications

    -

    1 For any type T, for each function std::meta::MOD defined in this clause, std::meta::MOD(^T) returns the reflection of the corresponding type std::MOD_t<T> as specified in 21.3.8.6 [meta.trans.ptr].

    -
    consteval info remove_pointer(info type);
    -consteval info add_pointer(info type);
    +

    1 For any type T, for each function std::meta::MOD defined in this clause, std::meta::MOD(^T) returns the reflection of the corresponding type std::MOD_t<T> as specified in 21.3.8.6 [meta.trans.ptr].

    +
    consteval info remove_pointer(info type);
    +consteval info add_pointer(info type);
    -

    5.2.4.11 [meta.reflection.trans.other], Other transformations

    +

    5.2.7.6 [meta.reflection.trans.other], Other transformations

    [ Editor's note: There are four transformations that are deliberately omitted here. type_identity and enable_if are not useful, conditional(cond, t, f) would just be a long way of writing cond ? t : f, and basic_common_reference is a class template intended to be specialized and not directly invoked. ]

    -

    1 For any type T, for each function std::meta::MOD defined in this clause with signature std::meta::info(std::meta::info), std::meta::MOD(^T) returns the reflection of the corresponding type std::MOD_t<T> as specified in 21.3.8.7 [meta.trans.other].

    -

    2 For any pack of types T..., for each function std::meta::VARIADIC-MOD defined in this clause with signature std::meta::info(std::span<const std::meta::info>), std::meta::VARIADIC-MOD({^T...}) returns the reflection of the corresponding type std::VARIADIC-MOD_t<T...> as specified in 21.3.8.7 [meta.trans.other].

    -

    3 For any type T and pack of types U..., std::meta::invoke_result(^T, {^u...}) returns the reflection of the corresponding type std::invoke_result_t<T, U...> (21.3.8.7 [meta.trans.other]).

    -
    consteval info remove_cvref(info type);
    -consteval info decay(info type);
    -consteval info common_type(span<const info> type_args);
    -consteval info common_reference(span<const info> type_args);
    -consteval info underlying_type(info type);
    -consteval info invoke_result(info type, span<const info> type_args);
    -consteval info unwrap_reference(info type);
    -consteval info unwrap_ref_decay(info type);
    -

    4 [Example:

    -
    // example implementation
    -consteval info unwrap_reference(info type) {
    -  if (has_template_arguments(type) && template_of(type) == ^reference_wrapper) {
    -    return add_lvalue_reference(template_arguments_of(type)[0]);
    -  } else {
    -    return type;
    -  }
    -}
    +

    1 For any type T, for each function std::meta::MOD defined in this clause with signature std::meta::info(std::meta::info), std::meta::MOD(^T) returns the reflection of the corresponding type std::MOD_t<T> as specified in 21.3.8.7 [meta.trans.other].

    +

    2 For any pack of types T..., for each function std::meta::VARIADIC-MOD defined in this clause with signature std::meta::info(std::span<const std::meta::info>), std::meta::VARIADIC-MOD({^T...}) returns the reflection of the corresponding type std::VARIADIC-MOD_t<T...> as specified in 21.3.8.7 [meta.trans.other].

    +

    3 For any type T and pack of types U..., std::meta::invoke_result(^T, {^u...}) returns the reflection of the corresponding type std::invoke_result_t<T, U...> (21.3.8.7 [meta.trans.other]).

    +
    consteval info remove_cvref(info type);
    +consteval info decay(info type);
    +consteval info common_type(span<const info> type_args);
    +consteval info common_reference(span<const info> type_args);
    +consteval info underlying_type(info type);
    +consteval info invoke_result(info type, span<const info> type_args);
    +consteval info unwrap_reference(info type);
    +consteval info unwrap_ref_decay(info type);
    +

    4 [Example:

    +
    // example implementation
    +consteval info unwrap_reference(info type) {
    +  if (has_template_arguments(type) && template_of(type) == ^reference_wrapper) {
    +    return add_lvalue_reference(template_arguments_of(type)[0]);
    +  } else {
    +    return type;
    +  }
    +}

    -end example]

    diff --git a/2996_reflection/reflection.md b/2996_reflection/reflection.md index 7ab69046..43186730 100644 --- a/2996_reflection/reflection.md +++ b/2996_reflection/reflection.md @@ -1828,6 +1828,16 @@ namespace std::meta { consteval info template_of(info r); consteval vector template_arguments_of(info r); + // [meta.reflection.member.queries], reflection member queries + template + consteval vector members_of(info r, Fs... filters); + template + consteval vector bases_of(info class_type, Fs... filters); + consteval vector static_data_members_of(info class_type); + consteval vector nonstatic_data_members_of(info class_type); + consteval vector subobjects_of(info class_type); + consteval vector enumerators_of(info enum_type); + // [meta.reflection.unary.cat], primary type categories consteval bool is_void(info type); consteval bool is_null_pointer(info type); @@ -2186,6 +2196,61 @@ static_assert(template_arguments_of(^PairPtr).size() == 1); ::: ::: +### [meta.reflection.member.queries], Reflection member queries + +::: bq +::: addu +```cpp +template + consteval vector members_of(info r, Fs... filters); +``` +[#]{.pnum} *Mandates*: `r` is a reflection designating either a class type or a namespace and `(std::predicate && ...)` is `true`. + +[#]{.pnum} *Returns*: A `vector` containing the reflections of all the members `m` of the entity designated by `r` such that `(filters(m) && ...)` is `true`, in the order in which they are declared. [Base classes precede any members and are returned in the order they are listed in the *base-specifier-list*.]{.note} + +```cpp +template + consteval vector bases_of(info class_type, Fs... filters); +``` + +[#]{.pnum} *Mandates*: `class_type` designates a class type. + +[#]{.pnum} *Effects*: Equivalent to `return members_of(class_type, is_base, filters...);` + +```cpp +consteval vector static_data_members_of(info class_type); +``` + +[#]{.pnum} *Mandates*: `class_type` designates a class type. + +[#]{.pnum} *Effects*: Equivalent to `return members_of(class_type, is_variable);` + +```cpp +consteval vector nonstatic_data_members_of(info class_type); +``` + +[#]{.pnum} *Mandates*: `class_type` designates a class type. + +[#]{.pnum} *Effects*: Equivalent to `return members_of(class_type, is_nsdm);` + +```cpp +consteval vector subobjects_of(info class_type); +``` + +[#]{.pnum} *Mandates*: `class_type` designates a class type. + +[#]{.pnum} *Returns*: A `vector` containing all the reflections in `bases_of(class_type)` followed by all the reflections in `nonstatic_data_members_of(class_type)`. + +```cpp +consteval vector enumerators_of(info enum_type); +``` + +[#]{.pnum} *Mandates*: `enum_type` designates an enumeration. + +[#]{.pnum} *Returns*: A `vector` containing the reflections of each enumerator of the enumeration designated by `enum_type`. +::: +::: + ### [meta.reflection.unary] Unary type traits ::: bq @@ -2343,11 +2408,13 @@ consteval size_t extent(info type, unsigned i = 0); ::: ::: -#### [meta.reflection.rel], Type relations +### [meta.reflection.rel], Type relations ::: bq ::: addu -[1]{.pnum} For any types `T` and `U`, for each function `std::meta::$REL$` defined in this clause with signature `bool(std::meta::info, std::meta::info)`, `std::meta::$REL$(^T, ^U)` equals the value of the corresponding type relation `std::$REL$_v` as specified in [meta.rel]{.sref}. +[1]{.pnum} The consteval functions specified in this clause may be used to query relationships between types at compile time. + +[#]{.pnum} For any types `T` and `U`, for each function `std::meta::$REL$` defined in this clause with signature `bool(std::meta::info, std::meta::info)`, `std::meta::$REL$(^T, ^U)` equals the value of the corresponding type relation `std::$REL$_v` as specified in [meta.rel]{.sref}. [#]{.pnum} For any type `T` and pack of types `U...`, for each function `std::meta::$VARIADIC-REL$` defined in this clause with signature `bool(std::meta::info, std::span)`, `std::meta::$VARIADIC-REL$(^T, {^U...})` equals the value of the corresponding type relation `std::$VARIADIC-REL$_v` as specified in [meta.rel]{.sref}. @@ -2373,6 +2440,14 @@ consteval bool is_nothrow_invocable_r(info result_type, info type, span