Difference between revisions of "cpp/experimental/reflect"
m (Now Reflection TS refers to C++20.) |
Andreas Krug (Talk | contribs) m (fmt) |
||
(4 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
− | {{title | Extensions for reflection}} | + | {{title|Extensions for reflection}} |
{{cpp/experimental/reflect/navbar}} | {{cpp/experimental/reflect/navbar}} | ||
− | The C++ Extensions for Reflection, ISO/IEC | + | The C++ Extensions for Reflection, ISO/IEC TS 23619:2021, specifies modifications to the core language and defines new components for the C++ standard library listed on this page. |
− | The Reflection TS is based on the C++20 standard. | + | The Reflection TS is based on the C++20 standard (except that the definition of concepts are specified in the style of [[cpp/experimental/constraints|Concepts TS]]). |
===Core language changes=== | ===Core language changes=== | ||
Line 12: | Line 12: | ||
{{spar|reflexpr-operand}} can be one of following: | {{spar|reflexpr-operand}} can be one of following: | ||
{{sdsc begin}} | {{sdsc begin}} | ||
− | {{sdsc | num=1 | {{ttb|::}} }} | + | {{sdsc|num=1|{{ttb|::}}}} |
− | {{sdsc | num=2 | {{spar|type-id}} }} | + | {{sdsc|num=2|{{spar|type-id}}}} |
− | {{sdsc | num=3 | {{spar|nested-name-specifier}}{{mark optional}} {{spar|namespace-name}} }} | + | {{sdsc|num=3|{{spar|nested-name-specifier}}{{mark optional}} {{spar|namespace-name}}}} |
− | {{sdsc | num=4 | {{spar|id-expression}} }} | + | {{sdsc|num=4|{{spar|id-expression}}}} |
− | {{sdsc | num=5 | {{ttb|(}} {{spar|expression}} {{ttb|)}} }} | + | {{sdsc|num=5|{{ttb|(}} {{spar|expression}} {{ttb|)}}}} |
− | {{sdsc | num=6 | {{spar|function-call-expression}} }} | + | {{sdsc|num=6|{{spar|function-call-expression}}}} |
− | {{sdsc | num=7 | {{spar|functional-type-conv-expression}} }} | + | {{sdsc|num=7|{{spar|functional-type-conv-expression}}}} |
{{sdsc end}} | {{sdsc end}} | ||
where {{spar|function-call-expression}} is | where {{spar|function-call-expression}} is | ||
{{sdsc begin}} | {{sdsc begin}} | ||
− | {{sdsc | | + | {{sdsc| |
− | {{spar|postfix-expression}} {{ttb|(}} {{spar|expression-list}}{{mark optional}} | + | {{spar|postfix-expression}} {{ttb|(}} {{spar|expression-list}}{{mark optional}} {{ttb|)}} |
}} | }} | ||
{{sdsc end}} | {{sdsc end}} | ||
Line 30: | Line 30: | ||
and {{spar|functional-type-conv-expression}} are following sorts of expressions which perform [[cpp/language/explicit cast|explict cast]]: | and {{spar|functional-type-conv-expression}} are following sorts of expressions which perform [[cpp/language/explicit cast|explict cast]]: | ||
{{sdsc begin}} | {{sdsc begin}} | ||
− | {{sdsc | num=1 | | + | {{sdsc|num=1| |
− | {{spar|simple-type-specifier}} {{ttb|(}} {{spar|expression-list}}{{mark optional}} | + | {{spar|simple-type-specifier}} {{ttb|(}} {{spar|expression-list}}{{mark optional}} {{ttb|)}} |
}} | }} | ||
− | {{sdsc | num=2 | | + | {{sdsc|num=2| |
− | {{spar|typename-specifier}} {{ttb|(}} {{spar|expression-list}}{{mark optional}} | + | {{spar|typename-specifier}} {{ttb|(}} {{spar|expression-list}}{{mark optional}} {{ttb|)}} |
}} | }} | ||
− | {{sdsc | num=3 | | + | {{sdsc|num=3| |
{{spar|simple-type-specifier}} {{spar|braced-init-list}} | {{spar|simple-type-specifier}} {{spar|braced-init-list}} | ||
}} | }} | ||
− | {{sdsc | num=4 | | + | {{sdsc|num=4| |
{{spar|typename-specifier}} {{spar|braced-init-list}} | {{spar|typename-specifier}} {{spar|braced-init-list}} | ||
}} | }} | ||
Line 48: | Line 48: | ||
For a {{spar|reflexpr-operand}} of form {{ttb|(}} {{spar|expression}} {{ttb|)}}, the {{spar|expression}} shall be a (possibly multi-parenthesized) {{spar|function-call-expression}} or {{spar|functional-type-conv-expression}}. | For a {{spar|reflexpr-operand}} of form {{ttb|(}} {{spar|expression}} {{ttb|)}}, the {{spar|expression}} shall be a (possibly multi-parenthesized) {{spar|function-call-expression}} or {{spar|functional-type-conv-expression}}. | ||
− | If | + | If an unparenthesized operand can be treated as either a {{spar|type-id}} or a {{spar|functional-type-conv-expression}}, then it is treated as a {{spar|type-id}}. Parenthesizes can be used for disambiguation between function-style cast and a {{spar|type-id}}. For example, given a class type {{tt|X}} with default constructor, {{c|reflexpr(X())}} reflects the function type {{c|X()}}, and {{c|reflexpr((X()))}} reflects the expression {{c|X()}}. |
If the operand designates both an alias and a class name, the type represented by the reflexpr-specifier reflects the alias and satisfies {{tt|reflect::Alias}}. | If the operand designates both an alias and a class name, the type represented by the reflexpr-specifier reflects the alias and satisfies {{tt|reflect::Alias}}. | ||
Line 67: | Line 67: | ||
{{source|1= | {{source|1= | ||
− | struct Functor { | + | struct Functor |
+ | { | ||
void operator()(int) const; | void operator()(int) const; | ||
Line 103: | Line 104: | ||
{{source|1= | {{source|1= | ||
struct X; | struct X; | ||
− | struct B { | + | struct B |
+ | { | ||
using X = ::X; | using X = ::X; | ||
typedef X Y; | typedef X Y; | ||
}; | }; | ||
− | struct D : B { | + | struct D : B |
+ | { | ||
using B::Y; | using B::Y; | ||
}; | }; | ||
Line 127: | Line 130: | ||
====Predefined feature testing macros==== | ====Predefined feature testing macros==== | ||
{{dsc begin}} | {{dsc begin}} | ||
− | {{dsc macro const | __cpp_reflection | notes={{mark since reflection ts}} | nolink=true | a value of at least {{c|201902}} indicates that the Reflection TS is supported }} | + | {{dsc macro const|__cpp_reflection|notes={{mark since reflection ts}}|nolink=true|a value of at least {{c|201902}} indicates that the Reflection TS is supported}} |
{{dsc end}} | {{dsc end}} | ||
Line 133: | Line 136: | ||
====Concepts==== | ====Concepts==== | ||
{{dsc begin}} | {{dsc begin}} | ||
− | {{dsc header | experimental/reflect}} | + | {{dsc header|experimental/reflect}} |
− | {{dsc namespace | std::experimental::reflect}} | + | {{dsc namespace|std::experimental::reflect}} |
− | {{dsc namespace | inline=true | std::experimental::reflect::v1}} | + | {{dsc namespace|inline=true|std::experimental::reflect::v1}} |
− | {{dsc concept | cpp/experimental/reflect/Object | notes={{mark since reflection ts}} | specifies that a type is a meta-object type}} | + | {{dsc concept|cpp/experimental/reflect/Object|notes={{mark since reflection ts}}|specifies that a type is a meta-object type}} |
− | {{dsc concept | cpp/experimental/reflect/ObjectSequence | notes={{mark since reflection ts}} | specifies that a meta-object type is a meta-object sequence type}} | + | {{dsc concept|cpp/experimental/reflect/ObjectSequence|notes={{mark since reflection ts}}|specifies that a meta-object type is a meta-object sequence type}} |
− | {{dsc concept | cpp/experimental/reflect/TemplateParameterScope | notes={{mark since reflection ts}} | specifies that a meta-object type reflects a template parameter scope}} | + | {{dsc concept|cpp/experimental/reflect/TemplateParameterScope|notes={{mark since reflection ts}}|specifies that a meta-object type reflects a template parameter scope}} |
− | {{dsc concept | cpp/experimental/reflect/Named | notes={{mark since reflection ts}} | specifies that a meta-object type reflects | + | {{dsc concept|cpp/experimental/reflect/Named|notes={{mark since reflection ts}}|specifies that a meta-object type reflects an entity or alias with an associated (possibly empty) name}} |
− | {{dsc concept | cpp/experimental/reflect/Alias | notes={{mark since reflection ts}} | specifies that a meta-object type reflects a type alias, namespace alias, or an alias introduced by a using-declaration}} | + | {{dsc concept|cpp/experimental/reflect/Alias|notes={{mark since reflection ts}}|specifies that a meta-object type reflects a type alias, namespace alias, or an alias introduced by a using-declaration}} |
− | {{dsc concept | cpp/experimental/reflect/RecordMember | notes={{mark since reflection ts}} | specifies that a meta-object type reflects a {{spar|member-declaration}} of a class}} | + | {{dsc concept|cpp/experimental/reflect/RecordMember|notes={{mark since reflection ts}}|specifies that a meta-object type reflects a {{spar|member-declaration}} of a class}} |
− | {{dsc concept | cpp/experimental/reflect/Enumerator | notes={{mark since reflection ts}} | specifies that a meta-object type reflects an enumerator}} | + | {{dsc concept|cpp/experimental/reflect/Enumerator|notes={{mark since reflection ts}}|specifies that a meta-object type reflects an enumerator}} |
− | {{dsc concept | cpp/experimental/reflect/Variable | notes={{mark since reflection ts}} | specifies that a meta-object type reflects a variable or data member}} | + | {{dsc concept|cpp/experimental/reflect/Variable|notes={{mark since reflection ts}}|specifies that a meta-object type reflects a variable or data member}} |
− | {{dsc concept | cpp/experimental/reflect/ScopeMember | notes={{mark since reflection ts}} | specifies that a meta-object type satisfies {{tt|RecordMember}}, {{tt|Enumerator}}, or {{tt|Variable}}, or reflects a namespace other than the global namespace}} | + | {{dsc concept|cpp/experimental/reflect/ScopeMember|notes={{mark since reflection ts}}|specifies that a meta-object type satisfies {{tt|RecordMember}}, {{tt|Enumerator}}, or {{tt|Variable}}, or reflects a namespace other than the global namespace}} |
− | {{dsc concept | cpp/experimental/reflect/Typed | notes={{mark since reflection ts}} | specifies that a meta-object type reflects an entity with a type}} | + | {{dsc concept|cpp/experimental/reflect/Typed|notes={{mark since reflection ts}}|specifies that a meta-object type reflects an entity with a type}} |
− | {{dsc concept | cpp/experimental/reflect/Namespace | notes={{mark since reflection ts}} | specifies that a meta-object type reflects a namespace}} | + | {{dsc concept|cpp/experimental/reflect/Namespace|notes={{mark since reflection ts}}|specifies that a meta-object type reflects a namespace}} |
− | {{dsc concept | cpp/experimental/reflect/GlobalScope | notes={{mark since reflection ts}} | specifies that a meta-object type reflects the global namespace}} | + | {{dsc concept|cpp/experimental/reflect/GlobalScope|notes={{mark since reflection ts}}|specifies that a meta-object type reflects the global namespace}} |
− | {{dsc concept | cpp/experimental/reflect/Class | notes={{mark since reflection ts}} | specifies that a meta-object type reflects a non-union class type}} | + | {{dsc concept|cpp/experimental/reflect/Class|notes={{mark since reflection ts}}|specifies that a meta-object type reflects a non-union class type}} |
− | {{dsc concept | cpp/experimental/reflect/Enum | notes={{mark since reflection ts}} | specifies that a meta-object type reflects an enumeration type}} | + | {{dsc concept|cpp/experimental/reflect/Enum|notes={{mark since reflection ts}}|specifies that a meta-object type reflects an enumeration type}} |
− | {{dsc concept | cpp/experimental/reflect/Record | notes={{mark since reflection ts}} | specifies that a meta-object type reflects a class type}} | + | {{dsc concept|cpp/experimental/reflect/Record|notes={{mark since reflection ts}}|specifies that a meta-object type reflects a class type}} |
− | {{dsc concept | cpp/experimental/reflect/Scope | notes={{mark since reflection ts}} | specifies that a meta-object type reflects a namespace, class, enumeration, function, closure type, a template parameter scope}} | + | {{dsc concept|cpp/experimental/reflect/Scope|notes={{mark since reflection ts}}|specifies that a meta-object type reflects a namespace, class, enumeration, function, closure type, a template parameter scope}} |
− | {{dsc concept | cpp/experimental/reflect/Type | notes={{mark since reflection ts}} | specifies that a meta-object type reflects a type}} | + | {{dsc concept|cpp/experimental/reflect/Type|notes={{mark since reflection ts}}|specifies that a meta-object type reflects a type}} |
− | {{dsc concept | cpp/experimental/reflect/Constant | notes={{mark since reflection ts}} | specifies that a meta-object type reflects an enumerator or a constexpr variable}} | + | {{dsc concept|cpp/experimental/reflect/Constant|notes={{mark since reflection ts}}|specifies that a meta-object type reflects an enumerator or a constexpr variable}} |
− | {{dsc concept | cpp/experimental/reflect/Base | notes={{mark since reflection ts}} | specifies that a meta-object type reflects a direct base class obtained from {{tt|get_base_classes}} }} | + | {{dsc concept|cpp/experimental/reflect/Base|notes={{mark since reflection ts}}|specifies that a meta-object type reflects a direct base class obtained from {{tt|get_base_classes}}}} |
− | {{dsc concept | cpp/experimental/reflect/FunctionParameter | notes={{mark since reflection ts}} | specifies that a meta-object type reflects a function parameter}} | + | {{dsc concept|cpp/experimental/reflect/FunctionParameter|notes={{mark since reflection ts}}|specifies that a meta-object type reflects a function parameter}} |
− | {{dsc concept | cpp/experimental/reflect/Callable | notes={{mark since reflection ts}} | specifies that a meta-object type reflects a function (including constructors and destructors)}} | + | {{dsc concept|cpp/experimental/reflect/Callable|notes={{mark since reflection ts}}|specifies that a meta-object type reflects a function (including constructors and destructors)}} |
− | {{dsc concept | cpp/experimental/reflect/Expression | notes={{mark since reflection ts}} | specifies that a meta-object type reflects an expression}} | + | {{dsc concept|cpp/experimental/reflect/Expression|notes={{mark since reflection ts}}|specifies that a meta-object type reflects an expression}} |
− | {{dsc concept | cpp/experimental/reflect/ParenthesizedExpression | notes={{mark since reflection ts}} | specifies that a meta-object type reflects a parenthesized expression}} | + | {{dsc concept|cpp/experimental/reflect/ParenthesizedExpression|notes={{mark since reflection ts}}|specifies that a meta-object type reflects a parenthesized expression}} |
− | {{dsc concept | cpp/experimental/reflect/FunctionCallExpression | notes={{mark since reflection ts}} | specifies that a meta-object type reflects a {{spar|function-call-expression}}}} | + | {{dsc concept|cpp/experimental/reflect/FunctionCallExpression|notes={{mark since reflection ts}}|specifies that a meta-object type reflects a {{spar|function-call-expression}}}} |
− | {{dsc concept | cpp/experimental/reflect/FunctionalTypeConversion | notes={{mark since reflection ts}} | specifies that a meta-object type reflects a {{spar|functional-type-conv-expression}}}} | + | {{dsc concept|cpp/experimental/reflect/FunctionalTypeConversion|notes={{mark since reflection ts}}|specifies that a meta-object type reflects a {{spar|functional-type-conv-expression}}}} |
− | {{dsc concept | cpp/experimental/reflect/Function | notes={{mark since reflection ts}} | specifies that a meta-object type reflects a function (excluding constructors and destructors)}} | + | {{dsc concept|cpp/experimental/reflect/Function|notes={{mark since reflection ts}}|specifies that a meta-object type reflects a function (excluding constructors and destructors)}} |
− | {{dsc concept | cpp/experimental/reflect/MemberFunction | notes={{mark since reflection ts}} | specifies that a meta-object type reflects a member function (excluding constructors and destructors)}} | + | {{dsc concept|cpp/experimental/reflect/MemberFunction|notes={{mark since reflection ts}}|specifies that a meta-object type reflects a member function (excluding constructors and destructors)}} |
− | {{dsc concept | cpp/experimental/reflect/SpecialMemberFunction | notes={{mark since reflection ts}} | specifies that a meta-object type reflects a special member function}} | + | {{dsc concept|cpp/experimental/reflect/SpecialMemberFunction|notes={{mark since reflection ts}}|specifies that a meta-object type reflects a special member function}} |
− | {{dsc concept | cpp/experimental/reflect/Constructor | notes={{mark since reflection ts}} | specifies that a meta-object type reflects a constructor}} | + | {{dsc concept|cpp/experimental/reflect/Constructor|notes={{mark since reflection ts}}|specifies that a meta-object type reflects a constructor}} |
− | {{dsc concept | cpp/experimental/reflect/Destructor | notes={{mark since reflection ts}} | specifies that a meta-object type reflects a destructor}} | + | {{dsc concept|cpp/experimental/reflect/Destructor|notes={{mark since reflection ts}}|specifies that a meta-object type reflects a destructor}} |
− | {{dsc concept | cpp/experimental/reflect/Operator | notes={{mark since reflection ts}} | specifies that a meta-object type reflects an operator function or a conversion function}} | + | {{dsc concept|cpp/experimental/reflect/Operator|notes={{mark since reflection ts}}|specifies that a meta-object type reflects an operator function or a conversion function}} |
− | {{dsc concept | cpp/experimental/reflect/ConversionOperator | notes={{mark since reflection ts}} | specifies that a meta-object type reflects a conversion function}} | + | {{dsc concept|cpp/experimental/reflect/ConversionOperator|notes={{mark since reflection ts}}|specifies that a meta-object type reflects a conversion function}} |
− | {{dsc concept | cpp/experimental/reflect/Lambda | notes={{mark since reflection ts}} | specifies that a meta-object type reflects the closure type of a non-generic lambda}} | + | {{dsc concept|cpp/experimental/reflect/Lambda|notes={{mark since reflection ts}}|specifies that a meta-object type reflects the closure type of a non-generic lambda}} |
− | {{dsc concept | cpp/experimental/reflect/LambdaCapture | notes={{mark since reflection ts}} | specifies that a meta-object type reflects a lambda capture}} | + | {{dsc concept|cpp/experimental/reflect/LambdaCapture|notes={{mark since reflection ts}}|specifies that a meta-object type reflects a lambda capture}} |
{{dsc end}} | {{dsc end}} | ||
====Meta-object operations==== | ====Meta-object operations==== | ||
{{dsc begin}} | {{dsc begin}} | ||
− | {{dsc header | experimental/reflect}} | + | {{dsc header|experimental/reflect}} |
− | {{dsc namespace | std::experimental::reflect}} | + | {{dsc namespace|std::experimental::reflect}} |
− | {{dsc namespace | inline=true | std::experimental::reflect::v1}} | + | {{dsc namespace|inline=true|std::experimental::reflect::v1}} |
− | {{dsc h2 | {{tt|Object}} operations}} | + | {{dsc h2|{{tt|Object}} operations}} |
− | {{dsc tclass | cpp/experimental/reflect/reflects_same | notes={{mark since reflection ts}} | checks if two meta-object types reflect the same entity or alias}} | + | {{dsc tclass|cpp/experimental/reflect/reflects_same|notes={{mark since reflection ts}}|checks if two meta-object types reflect the same entity or alias}} |
− | {{dsc tclass | cpp/experimental/reflect/get_source_line | notes={{mark since reflection ts}} | obtains the presumed line number of the declaration of the reflected entity or alias}} | + | {{dsc tclass|cpp/experimental/reflect/get_source_line|notes={{mark since reflection ts}}|obtains the presumed line number of the declaration of the reflected entity or alias}} |
− | {{dsc tclass | cpp/experimental/reflect/get_source_column | notes={{mark since reflection ts}} | obtains the implementation-defined column number of the declaration of the reflected entity or alias}} | + | {{dsc tclass|cpp/experimental/reflect/get_source_column|notes={{mark since reflection ts}}|obtains the implementation-defined column number of the declaration of the reflected entity or alias}} |
− | {{dsc tclass | cpp/experimental/reflect/get_source_file_name | notes={{mark since reflection ts}} | obtains the presumed file name of the declaration of the reflected entity or alias}} | + | {{dsc tclass|cpp/experimental/reflect/get_source_file_name|notes={{mark since reflection ts}}|obtains the presumed file name of the declaration of the reflected entity or alias}} |
− | {{dsc h2 | {{tt|ObjectSequence}} operations}} | + | {{dsc h2|{{tt|ObjectSequence}} operations}} |
− | {{dsc tclass | cpp/experimental/reflect/get_size | notes={{mark since reflection ts}} | obtains the size of a meta-object sequence}} | + | {{dsc tclass|cpp/experimental/reflect/get_size|notes={{mark since reflection ts}}|obtains the size of a meta-object sequence}} |
− | {{dsc tclass | cpp/experimental/reflect/get_element | notes={{mark since reflection ts}} | obtains the meta-object type with specified index in a sequence}} | + | {{dsc tclass|cpp/experimental/reflect/get_element|notes={{mark since reflection ts}}|obtains the meta-object type with specified index in a sequence}} |
− | {{dsc tclass | cpp/experimental/reflect/unpack_sequence | notes={{mark since reflection ts}} | applies a template to the meta-object sequence}} | + | {{dsc tclass|cpp/experimental/reflect/unpack_sequence|notes={{mark since reflection ts}}|applies a template to the meta-object sequence}} |
− | {{dsc h2 | {{tt|Named}} operations}} | + | {{dsc h2|{{tt|Named}} operations}} |
− | {{dsc tclass | cpp/experimental/reflect/is_unnamed | notes={{mark since reflection ts}} | checks if the reflected entity or alias is unnamed}} | + | {{dsc tclass|cpp/experimental/reflect/is_unnamed|notes={{mark since reflection ts}}|checks if the reflected entity or alias is unnamed}} |
− | {{dsc tclass | cpp/experimental/reflect/get_name | notes={{mark since reflection ts}} | obtains the unqualified name of the reflected entity or alias}} | + | {{dsc tclass|cpp/experimental/reflect/get_name|notes={{mark since reflection ts}}|obtains the unqualified name of the reflected entity or alias}} |
− | {{dsc tclass | cpp/experimental/reflect/get_display_name | notes={{mark since reflection ts}} | obtains the implementation-defined display name of the reflected entity or alias}} | + | {{dsc tclass|cpp/experimental/reflect/get_display_name|notes={{mark since reflection ts}}|obtains the implementation-defined display name of the reflected entity or alias}} |
− | {{dsc h2 | {{tt|Alias}} operations}} | + | {{dsc h2|{{tt|Alias}} operations}} |
− | {{dsc tclass | cpp/experimental/reflect/get_alias | notes={{mark since reflection ts}} | obtains the meta-object type reflecting the associated entity of the reflected alias}} | + | {{dsc tclass|cpp/experimental/reflect/get_alias|notes={{mark since reflection ts}}|obtains the meta-object type reflecting the associated entity of the reflected alias}} |
− | {{dsc h2 | {{tt|Type}} operations}} | + | {{dsc h2|{{tt|Type}} operations}} |
− | {{dsc tclass | cpp/experimental/reflect/get_type | notes={{mark since reflection ts}} | obtains the meta-object type reflecting the type of the reflected entity or alias}} | + | {{dsc tclass|cpp/experimental/reflect/get_type|notes={{mark since reflection ts}}|obtains the meta-object type reflecting the type of the reflected entity or alias}} |
− | {{dsc tclass | cpp/experimental/reflect/get_reflected_type | notes={{mark since reflection ts}} | obtains the type of the reflected entity or alias}} | + | {{dsc tclass|cpp/experimental/reflect/get_reflected_type|notes={{mark since reflection ts}}|obtains the type of the reflected entity or alias}} |
− | {{dsc tclass | cpp/experimental/reflect/is_enum | notes={{mark since reflection ts}} | checks if the meta-object type reflects an enumeration type}} | + | {{dsc tclass|cpp/experimental/reflect/is_enum|notes={{mark since reflection ts}}|checks if the meta-object type reflects an enumeration type}} |
− | {{dsc tclass | cpp/experimental/reflect/is_union | notes={{mark since reflection ts}} | checks if the meta-object type reflects a union type}} | + | {{dsc tclass|cpp/experimental/reflect/is_union|notes={{mark since reflection ts}}|checks if the meta-object type reflects a union type}} |
− | {{dsc tclass | cpp/experimental/reflect/uses_key | title=uses_class_key<br>uses_struct_key | notes={{mark since reflection ts}} | checks if the meta-object type reflects a non-union class type whose declaration uses {{c|class}} or {{c|struct}} respectively}} | + | {{dsc tclass|cpp/experimental/reflect/uses_key|title=uses_class_key<br>uses_struct_key|notes={{mark since reflection ts}}|checks if the meta-object type reflects a non-union class type whose declaration uses {{c|class}} or {{c|struct}} respectively}} |
− | {{dsc h2 | {{tt|ScopeMember}} operations}} | + | {{dsc h2|{{tt|ScopeMember}} operations}} |
− | {{dsc tclass | cpp/experimental/reflect/get_scope | notes={{mark since reflection ts}} | obtains the meta-object type reflecting the scope of the reflected entity or alias}} | + | {{dsc tclass|cpp/experimental/reflect/get_scope|notes={{mark since reflection ts}}|obtains the meta-object type reflecting the scope of the reflected entity or alias}} |
− | {{dsc h2 | {{tt|Base}} operations}} | + | {{dsc h2|{{tt|Base}} operations}} |
− | {{dsc tclass | cpp/experimental/reflect/get_class | notes={{mark since reflection ts}} | obtains the meta-object type reflecting the base class in the given base class relationship}} | + | {{dsc tclass|cpp/experimental/reflect/get_class|notes={{mark since reflection ts}}|obtains the meta-object type reflecting the base class in the given base class relationship}} |
− | {{dsc h2 | {{tt|RecordMember}} and {{tt|Base}} operations}} | + | {{dsc h2|{{tt|RecordMember}} and {{tt|Base}} operations}} |
− | {{dsc tclass | cpp/experimental/reflect/is_public | notes={{mark since reflection ts}} | checks if the reflected member or base class is public}} | + | {{dsc tclass|cpp/experimental/reflect/is_public|notes={{mark since reflection ts}}|checks if the reflected member or base class is public}} |
− | {{dsc tclass | cpp/experimental/reflect/is_protected | notes={{mark since reflection ts}} | checks if the reflected member or base class is protected}} | + | {{dsc tclass|cpp/experimental/reflect/is_protected|notes={{mark since reflection ts}}|checks if the reflected member or base class is protected}} |
− | {{dsc tclass | cpp/experimental/reflect/is_private | notes={{mark since reflection ts}} | checks if the reflected member or base class is private}} | + | {{dsc tclass|cpp/experimental/reflect/is_private|notes={{mark since reflection ts}}|checks if the reflected member or base class is private}} |
− | {{dsc h2 | {{tt|Record}} operations}} | + | {{dsc h2|{{tt|Record}} operations}} |
− | {{dsc tclass | cpp/experimental/reflect/get_data_members | title=get_public_data_members<br>get_accessible_data_members<br>get_data_members | notes={{mark since reflection ts}} | obtains a meta-object sequence type whose elements reflect public, accessible, or all data members of the reflected class}} | + | {{dsc tclass|cpp/experimental/reflect/get_data_members|title=get_public_data_members<br>get_accessible_data_members<br>get_data_members|notes={{mark since reflection ts}}|obtains a meta-object sequence type whose elements reflect public, accessible, or all data members of the reflected class}} |
− | {{dsc tclass | cpp/experimental/reflect/get_member_functions | title=get_public_member_functions<br>get_accessible_member_functions<br>get_member_functions | notes={{mark since reflection ts}} | obtains a meta-object sequence type whose elements reflect public, accessible, or all member functions of the reflected class}} | + | {{dsc tclass|cpp/experimental/reflect/get_member_functions|title=get_public_member_functions<br>get_accessible_member_functions<br>get_member_functions|notes={{mark since reflection ts}}|obtains a meta-object sequence type whose elements reflect public, accessible, or all member functions of the reflected class}} |
− | {{dsc tclass | cpp/experimental/reflect/get_constructors | notes={{mark since reflection ts}} | obtains a meta-object sequence type whose elements reflect all constructors of the reflected class}} | + | {{dsc tclass|cpp/experimental/reflect/get_constructors|notes={{mark since reflection ts}}|obtains a meta-object sequence type whose elements reflect all constructors of the reflected class}} |
− | {{dsc tclass | cpp/experimental/reflect/get_operators | notes={{mark since reflection ts}} | obtains a meta-object sequence type whose elements reflect all operator functions and conversion functions declared in the reflected class}} | + | {{dsc tclass|cpp/experimental/reflect/get_operators|notes={{mark since reflection ts}}|obtains a meta-object sequence type whose elements reflect all operator functions and conversion functions declared in the reflected class}} |
− | {{dsc tclass | cpp/experimental/reflect/get_destructor | notes={{mark since reflection ts}} | obtains the meta-object type reflecting the destructor of the reflected class}} | + | {{dsc tclass|cpp/experimental/reflect/get_destructor|notes={{mark since reflection ts}}|obtains the meta-object type reflecting the destructor of the reflected class}} |
− | {{dsc tclass | cpp/experimental/reflect/get_member_types | title=get_public_member_types<br>get_accessible_member_types<br>get_member_types | notes={{mark since reflection ts}} | obtains a meta-object sequence type whose elements reflect public, accessible, or all nested type or member typedefs of the reflected class}} | + | {{dsc tclass|cpp/experimental/reflect/get_member_types|title=get_public_member_types<br>get_accessible_member_types<br>get_member_types|notes={{mark since reflection ts}}|obtains a meta-object sequence type whose elements reflect public, accessible, or all nested type or member typedefs of the reflected class}} |
− | {{dsc tclass | cpp/experimental/reflect/get_base_classes | title=get_public_base_classes<br>get_accessible_base_classes<br>get_base_classes | notes={{mark since reflection ts}} | obtains a meta-object sequence type whose elements reflect public, accessible, or all base classes of the reflected class}} | + | {{dsc tclass|cpp/experimental/reflect/get_base_classes|title=get_public_base_classes<br>get_accessible_base_classes<br>get_base_classes|notes={{mark since reflection ts}}|obtains a meta-object sequence type whose elements reflect public, accessible, or all base classes of the reflected class}} |
− | {{dsc h2 | {{tt|Enum}} operations}} | + | {{dsc h2|{{tt|Enum}} operations}} |
− | {{dsc tclass | cpp/experimental/reflect/is_scoped_enum | notes={{mark since reflection ts}} | checks whether the reflected enumeration is scoped}} | + | {{dsc tclass|cpp/experimental/reflect/is_scoped_enum|notes={{mark since reflection ts}}|checks whether the reflected enumeration is scoped}} |
− | {{dsc tclass | cpp/experimental/reflect/get_enumerators | notes={{mark since reflection ts}} | obtains a meta-object sequence type whose elements reflects the enumerators of the reflected enumeration}} | + | {{dsc tclass|cpp/experimental/reflect/get_enumerators|notes={{mark since reflection ts}}|obtains a meta-object sequence type whose elements reflects the enumerators of the reflected enumeration}} |
− | {{dsc tclass | cpp/experimental/reflect/get_underlying_type | notes={{mark since reflection ts}} | obtains the meta-object type reflecting the underlying type of the reflected enumeration}} | + | {{dsc tclass|cpp/experimental/reflect/get_underlying_type|notes={{mark since reflection ts}}|obtains the meta-object type reflecting the underlying type of the reflected enumeration}} |
− | {{dsc h2 | {{tt|Variable}} operations}} | + | {{dsc h2|{{tt|Variable}} operations}} |
− | {{dsc tclass | cpp/experimental/reflect/get_constant | notes={{mark since reflection ts}} | obtains the value of the reflected variable which is a constant expression}} | + | {{dsc tclass|cpp/experimental/reflect/get_constant|notes={{mark since reflection ts}}|obtains the value of the reflected variable which is a constant expression}} |
− | {{dsc tclass | cpp/experimental/reflect/is_thread_local | notes={{mark since reflection ts}} | checks if the variable is declared with {{c|thread_local}} }} | + | {{dsc tclass|cpp/experimental/reflect/is_thread_local|notes={{mark since reflection ts}}|checks if the variable is declared with {{c|thread_local}}}} |
− | {{dsc h2 | {{tt|FunctionParameter}} operations}} | + | {{dsc h2|{{tt|FunctionParameter}} operations}} |
− | {{dsc tclass | cpp/experimental/reflect/has_default_argument | notes={{mark since reflection ts}} | checks whether the reflected parameter has a default argument}} | + | {{dsc tclass|cpp/experimental/reflect/has_default_argument|notes={{mark since reflection ts}}|checks whether the reflected parameter has a default argument}} |
− | {{dsc h2 | {{tt|Callable}} operations}} | + | {{dsc h2|{{tt|Callable}} operations}} |
− | {{dsc tclass | cpp/experimental/reflect/get_parameters | notes={{mark since reflection ts}} | obtains a meta-object sequence type whose elements reflects the parameters of the reflected function}} | + | {{dsc tclass|cpp/experimental/reflect/get_parameters|notes={{mark since reflection ts}}|obtains a meta-object sequence type whose elements reflects the parameters of the reflected function}} |
− | {{dsc tclass | cpp/experimental/reflect/is_vararg | notes={{mark since reflection ts}} | checks whether the parameter list of the reflected function contains an ellipsis parameter}} | + | {{dsc tclass|cpp/experimental/reflect/is_vararg|notes={{mark since reflection ts}}|checks whether the parameter list of the reflected function contains an ellipsis parameter}} |
− | {{dsc tclass | cpp/experimental/reflect/is_noexcept | notes={{mark since reflection ts}} | checks whether the reflected function is non-throwing}} | + | {{dsc tclass|cpp/experimental/reflect/is_noexcept|notes={{mark since reflection ts}}|checks whether the reflected function is non-throwing}} |
− | {{dsc tclass | cpp/experimental/reflect/is_deleted | notes={{mark since reflection ts}} | checks whether the reflected function is deleted}} | + | {{dsc tclass|cpp/experimental/reflect/is_deleted|notes={{mark since reflection ts}}|checks whether the reflected function is deleted}} |
− | {{dsc h2 | {{tt|Variable}} and {{tt|Callable}} operations}} | + | {{dsc h2|{{tt|Variable}} and {{tt|Callable}} operations}} |
− | {{dsc tclass | cpp/experimental/reflect/is_constexpr | notes={{mark since reflection ts}} | checks if the reflected variable or function is constexpr}} | + | {{dsc tclass|cpp/experimental/reflect/is_constexpr|notes={{mark since reflection ts}}|checks if the reflected variable or function is constexpr}} |
− | {{dsc h2 | {{tt|Namespace}} and {{tt|Callable}} operations}} | + | {{dsc h2|{{tt|Namespace}} and {{tt|Callable}} operations}} |
− | {{dsc tclass | cpp/experimental/reflect/is_inline | notes={{mark since reflection ts}} | checks whether the reflected namespace or function is inline}} | + | {{dsc tclass|cpp/experimental/reflect/is_inline|notes={{mark since reflection ts}}|checks whether the reflected namespace or function is inline}} |
− | {{dsc h2 | {{tt|ParenthesizedExpression}} operations}} | + | {{dsc h2|{{tt|ParenthesizedExpression}} operations}} |
− | {{dsc tclass | cpp/experimental/reflect/get_subexpression | notes={{mark since reflection ts}} | obtains the meta-object type reflecting the unparenthesized expression of the reflected parethesized expression}} | + | {{dsc tclass|cpp/experimental/reflect/get_subexpression|notes={{mark since reflection ts}}|obtains the meta-object type reflecting the unparenthesized expression of the reflected parethesized expression}} |
− | {{dsc h2 | {{tt|FunctionCallExpression}} operations}} | + | {{dsc h2|{{tt|FunctionCallExpression}} operations}} |
− | {{dsc tclass | cpp/experimental/reflect/get_callable | notes={{mark since reflection ts}} | obtains the meta-object type reflecting the function in the reflected {{spar|function-call-expression}} }} | + | {{dsc tclass|cpp/experimental/reflect/get_callable|notes={{mark since reflection ts}}|obtains the meta-object type reflecting the function in the reflected {{spar|function-call-expression}}}} |
− | {{dsc h2 | {{tt|FunctionalTypeConversion}} operations}} | + | {{dsc h2|{{tt|FunctionalTypeConversion}} operations}} |
− | {{dsc tclass | cpp/experimental/reflect/get_constructor | notes={{mark since reflection ts}} | obtains the meta-object type reflecting the constructor in reflected {{spar|functional-type-conv-expression}} }} | + | {{dsc tclass|cpp/experimental/reflect/get_constructor|notes={{mark since reflection ts}}|obtains the meta-object type reflecting the constructor in reflected {{spar|functional-type-conv-expression}}}} |
− | {{dsc h2 | {{tt|Variable}} and {{tt|Function}} operations}} | + | {{dsc h2|{{tt|Variable}} and {{tt|Function}} operations}} |
− | {{dsc tclass | cpp/experimental/reflect/get_pointer | notes={{mark since reflection ts}} | get the address of the reflected variable or function, or the pointer-to-member value to the reflected non-static member}} | + | {{dsc tclass|cpp/experimental/reflect/get_pointer|notes={{mark since reflection ts}}|get the address of the reflected variable or function, or the pointer-to-member value to the reflected non-static member}} |
− | {{dsc h2 | {{tt|MemberFunction}} operations}} | + | {{dsc h2|{{tt|MemberFunction}} operations}} |
− | {{dsc tclass | cpp/experimental/reflect/is_qualified | title=is_const<br>is_volatile<br>has_lvalueref_qualifier<br>has_rvalueref_qualifier | notes={{mark since reflection ts}} | checks if the reflected member function is declared with {{c|const}}, {{c|volatile}}, {{c|&}}, or {{c|&&}} qualifier respectively}} | + | {{dsc tclass|cpp/experimental/reflect/is_qualified|title=is_const<br>is_volatile<br>has_lvalueref_qualifier<br>has_rvalueref_qualifier|notes={{mark since reflection ts}}|checks if the reflected member function is declared with {{c|const}}, {{c|volatile}}, {{c|&}}, or {{c|&&}} qualifier respectively}} |
− | {{dsc tclass | cpp/experimental/reflect/is_override | notes={{mark since reflection ts}} | checks if the reflected member function overrides a member function of base class}} | + | {{dsc tclass|cpp/experimental/reflect/is_override|notes={{mark since reflection ts}}|checks if the reflected member function overrides a member function of base class}} |
− | {{dsc h2 | {{tt|Record}} and {{tt|MemberFunction}} operations}} | + | {{dsc h2|{{tt|Record}} and {{tt|MemberFunction}} operations}} |
− | {{dsc tclass | cpp/experimental/reflect/is_final | notes={{mark since reflection ts}} | checks if the reflected class or member function is marked with {{c|final}} }} | + | {{dsc tclass|cpp/experimental/reflect/is_final|notes={{mark since reflection ts}}|checks if the reflected class or member function is marked with {{c|final}}}} |
− | {{dsc h2 | {{tt|Variable}} and {{tt|MemberFunction}} operations}} | + | {{dsc h2|{{tt|Variable}} and {{tt|MemberFunction}} operations}} |
− | {{dsc tclass | cpp/experimental/reflect/is_static | notes={{mark since reflection ts}} | checks if the reflected variable is of static storage duration, or the reflected member function is static}} | + | {{dsc tclass|cpp/experimental/reflect/is_static|notes={{mark since reflection ts}}|checks if the reflected variable is of static storage duration, or the reflected member function is static}} |
− | {{dsc h2 | {{tt|SpecialMemberFunction}} operations}} | + | {{dsc h2|{{tt|SpecialMemberFunction}} operations}} |
− | {{dsc tclass | cpp/experimental/reflect/is_implicitly_declared | notes={{mark since reflection ts}} | checks if the reflected special member function is implicitly declared}} | + | {{dsc tclass|cpp/experimental/reflect/is_implicitly_declared|notes={{mark since reflection ts}}|checks if the reflected special member function is implicitly declared}} |
− | {{dsc tclass | cpp/experimental/reflect/is_defaulted | notes={{mark since reflection ts}} | checks if the reflected special member function is defaulted in its first declaration}} | + | {{dsc tclass|cpp/experimental/reflect/is_defaulted|notes={{mark since reflection ts}}|checks if the reflected special member function is defaulted in its first declaration}} |
− | {{dsc h2 | {{tt|Constructor}} and {{tt|ConversionOperator}} operations}} | + | {{dsc h2|{{tt|Constructor}} and {{tt|ConversionOperator}} operations}} |
− | {{dsc tclass | cpp/experimental/reflect/is_explicit | notes={{mark since reflection ts}} | checks if the reflected constructor or conversion function is declared with {{c|explicit}} }} | + | {{dsc tclass|cpp/experimental/reflect/is_explicit|notes={{mark since reflection ts}}|checks if the reflected constructor or conversion function is declared with {{c|explicit}}}} |
− | {{dsc h2 | {{tt|MemberFunction}} and {{tt|Destructor}} operations}} | + | {{dsc h2|{{tt|MemberFunction}} and {{tt|Destructor}} operations}} |
− | {{dsc tclass | cpp/experimental/reflect/is_virtual | notes={{mark since reflection ts}} | checks if the reflected member function is virtual}} | + | {{dsc tclass|cpp/experimental/reflect/is_virtual|notes={{mark since reflection ts}}|checks if the reflected member function is virtual}} |
− | {{dsc tclass | cpp/experimental/reflect/is_pure_virtual | notes={{mark since reflection ts}} | checks if the reflected member function is pure virtual}} | + | {{dsc tclass|cpp/experimental/reflect/is_pure_virtual|notes={{mark since reflection ts}}|checks if the reflected member function is pure virtual}} |
− | {{dsc h2 | {{tt|Lambda}} operations}} | + | {{dsc h2|{{tt|Lambda}} operations}} |
− | {{dsc tclass | cpp/experimental/reflect/get_captures | notes={{mark since reflection ts}} | obtains a meta-object sequence type whose elements reflect the captures of the reflected closure type}} | + | {{dsc tclass|cpp/experimental/reflect/get_captures|notes={{mark since reflection ts}}|obtains a meta-object sequence type whose elements reflect the captures of the reflected closure type}} |
− | {{dsc tclass | cpp/experimental/reflect/uses_default_capture | title=uses_default_copy_capture<br>uses_default_reference_capture | notes={{mark since reflection ts}} | checks if the capture-default of the lambda expression of the reflected closure type is {{tt|1==}} or {{tt|&}} respectively}} | + | {{dsc tclass|cpp/experimental/reflect/uses_default_capture|title=uses_default_copy_capture<br>uses_default_reference_capture|notes={{mark since reflection ts}}|checks if the capture-default of the lambda expression of the reflected closure type is {{tt|1==}} or {{tt|&}} respectively}} |
− | {{dsc tclass | cpp/experimental/reflect/is_call_operator_const | notes={{mark since reflection ts}} | checks if the {{tt|operator()}} of the reflected closure type is declared with {{c|const}} }} | + | {{dsc tclass|cpp/experimental/reflect/is_call_operator_const|notes={{mark since reflection ts}}|checks if the {{tt|operator()}} of the reflected closure type is declared with {{c|const}}}} |
− | {{dsc h2 | {{tt|LambdaCapture}} operations}} | + | {{dsc h2|{{tt|LambdaCapture}} operations}} |
− | {{dsc tclass | cpp/experimental/reflect/is_explictly_captured | notes={{mark since reflection ts}} | checks if the reflected lambda capture is explicitly captured }} | + | {{dsc tclass|cpp/experimental/reflect/is_explictly_captured|notes={{mark since reflection ts}}|checks if the reflected lambda capture is explicitly captured}} |
− | {{dsc tclass | cpp/experimental/reflect/is_init_capture | notes={{mark since reflection ts}} | checks if the reflected lambda capture is an init-capture}} | + | {{dsc tclass|cpp/experimental/reflect/is_init_capture|notes={{mark since reflection ts}}|checks if the reflected lambda capture is an init-capture}} |
{{dsc end}} | {{dsc end}} | ||
====Library feature testing macros==== | ====Library feature testing macros==== | ||
{{dsc begin}} | {{dsc begin}} | ||
− | {{dsc header | experimental/reflect}} | + | {{dsc header|experimental/reflect}} |
− | {{dsc macro const | __cpp_lib_reflection | notes={{mark since reflection ts}} | nolink=true | a value of at least {{c|201902}} indicates that the support library of the Reflection TS is supported }} | + | {{dsc macro const|__cpp_lib_reflection|notes={{mark since reflection ts}}|nolink=true|a value of at least {{c|201902}} indicates that the support library of the Reflection TS is supported}} |
{{dsc end}} | {{dsc end}} | ||
====Satisfaction of concepts==== | ====Satisfaction of concepts==== | ||
The following table lists that whether a meta-object type reflecting an operand satisfies concepts introduced by the Reflection TS. | The following table lists that whether a meta-object type reflecting an operand satisfies concepts introduced by the Reflection TS. | ||
− | {| table class="wikitable" | + | {|table class="wikitable" |
− | ! Category | + | !Category |
− | ! {{tt|reflexpr}} operands | + | !{{tt|reflexpr}} operands |
− | ! Satisfied concepts | + | !Satisfied concepts |
|- | |- | ||
− | | rowspan="9" | Type | + | |rowspan="9"|Type |
− | | {{spar|class-name}} designating a [[cpp/language/union|union]] | + | |{{spar|class-name}} designating a [[cpp/language/union|union]] |
− | | {{tt|reflect::Union}} | + | |{{tt|reflect::Union}} |
|- | |- | ||
− | | {{spar|class-name}} designating a [[cpp/language/lambda|closure type]] | + | |{{spar|class-name}} designating a [[cpp/language/lambda|closure type]] |
− | | {{tt|reflect::Lambda}} | + | |{{tt|reflect::Lambda}} |
|- | |- | ||
− | | {{spar|class-name}} designating a non-union class | + | |{{spar|class-name}} designating a non-union class |
− | | {{tt|reflect::Record}} | + | |{{tt|reflect::Record}} |
|- | |- | ||
− | | [[cpp/language/enum|{{spar|enum-name}}]] | + | |[[cpp/language/enum|{{spar|enum-name}}]] |
− | | {{tt|reflect::Enum}} | + | |{{tt|reflect::Enum}} |
|- | |- | ||
− | | [[cpp/language/template parameters#Type template parameter|template {{spar|type-parameter}}]] | + | |[[cpp/language/template parameters#Type template parameter|template {{spar|type-parameter}}]] |
− | | {{tt|reflect::Type}}, {{tt|reflect::Alias}} | + | |{{tt|reflect::Type}}, {{tt|reflect::Alias}} |
|- | |- | ||
− | | [[cpp/language/decltype|{{spar|decltype-specifier}}]] | + | |[[cpp/language/decltype|{{spar|decltype-specifier}}]] |
− | | {{tt|reflect::Type}}, {{tt|reflect::Alias}} | + | |{{tt|reflect::Type}}, {{tt|reflect::Alias}} |
|- | |- | ||
− | | {{spar|type-name}} introduced by a [[cpp/language/namespace#Using-declarations|using-declaration]] | + | |{{spar|type-name}} introduced by a [[cpp/language/namespace#Using-declarations|using-declaration]] |
− | | {{tt|reflect::Type}}, {{tt|reflect::Alias}}, {{tt|reflect::ScopedMember}} | + | |{{tt|reflect::Type}}, {{tt|reflect::Alias}}, {{tt|reflect::ScopedMember}} |
|- | |- | ||
− | | any other {{spar|typedef-name}} | + | |any other {{spar|typedef-name}} |
− | | {{tt|reflect::Type}}, {{tt|reflect::Alias}} | + | |{{tt|reflect::Type}}, {{tt|reflect::Alias}} |
|- | |- | ||
− | | any other {{spar|type-id}} | + | |any other {{spar|type-id}} |
− | | {{tt|reflect::Type}} | + | |{{tt|reflect::Type}} |
|- | |- | ||
− | | rowspan="3" | Namespace | + | |rowspan="3"|Namespace |
− | | [[cpp/language/namespace alias|{{spar|namespace-alias}}]] | + | |[[cpp/language/namespace alias|{{spar|namespace-alias}}]] |
− | | {{tt|reflect::Namespace}}, {{tt|reflect::Alias}} | + | |{{tt|reflect::Namespace}}, {{tt|reflect::Alias}} |
|- | |- | ||
− | | the global namespace | + | |the global namespace |
− | | {{tt|reflect::GlobalScope}} | + | |{{tt|reflect::GlobalScope}} |
|- | |- | ||
− | | any other [[cpp/language/namespace|namespace]] | + | |any other [[cpp/language/namespace|namespace]] |
− | | {{tt|reflect::Namespace}} | + | |{{tt|reflect::Namespace}} |
|- | |- | ||
− | | rowspan="8" | Expression | + | |rowspan="8"|Expression |
− | | the name of a data member | + | |the name of a data member |
− | | {{tt|reflect::Variable}} | + | |{{tt|reflect::Variable}} |
|- | |- | ||
− | | the name of a variable | + | |the name of a variable |
− | | {{tt|reflect::Variable}} | + | |{{tt|reflect::Variable}} |
|- | |- | ||
− | | the name of an enumerator | + | |the name of an enumerator |
− | | {{tt|reflect::Enumerator}} | + | |{{tt|reflect::Enumerator}} |
|- | |- | ||
− | | the name of a function parameter | + | |the name of a function parameter |
− | | {{tt|reflect::FunctionParameter}} | + | |{{tt|reflect::FunctionParameter}} |
|- | |- | ||
− | | the name of a [[cpp/language/lambda#Lambda capture|captured entity]] | + | |the name of a [[cpp/language/lambda#Lambda capture|captured entity]] |
− | | {{tt|reflect::LambdaCapture}} | + | |{{tt|reflect::LambdaCapture}} |
|- | |- | ||
− | | parenthesized expression | + | |parenthesized expression |
− | | {{tt|reflect::ParenthesizedExpression}} | + | |{{tt|reflect::ParenthesizedExpression}} |
|- | |- | ||
− | | {{spar|function-call-expression}} | + | |{{spar|function-call-expression}} |
− | | {{tt|reflect::FunctionCallExpression}} | + | |{{tt|reflect::FunctionCallExpression}} |
|- | |- | ||
− | | {{spar|functional-type-conv-expression}} | + | |{{spar|functional-type-conv-expression}} |
− | | {{tt|reflect::FunctionalTypeConversion}} | + | |{{tt|reflect::FunctionalTypeConversion}} |
|} | |} | ||
Line 374: | Line 377: | ||
===See also=== | ===See also=== | ||
{{dsc begin}} | {{dsc begin}} | ||
− | {{dsc inc | cpp/types/dsc type_info}} | + | {{dsc inc|cpp/types/dsc type_info}} |
− | {{dsc inc | cpp/header/dsc type_traits}} | + | {{dsc inc|cpp/header/dsc type_traits}} |
− | <!--{{dsc | [[cpp/experimental/meta/P1717|Compile-time Metaprogramming in C++]] }}--> | + | <!--{{dsc|[[cpp/experimental/meta/P1717|Compile-time Metaprogramming in C++]]}}--> |
{{dsc end}} | {{dsc end}} | ||
{{langlinks|es|ja|ru|zh}} | {{langlinks|es|ja|ru|zh}} |
Latest revision as of 01:08, 1 December 2023
The C++ Extensions for Reflection, ISO/IEC TS 23619:2021, specifies modifications to the core language and defines new components for the C++ standard library listed on this page.
The Reflection TS is based on the C++20 standard (except that the definition of concepts are specified in the style of Concepts TS).
[edit] Core language changes
[edit] reflexpr-specifier
A reflexpr-specifier is of form reflexpr
(
reflexpr-operand )
, and specifies a meta-object type (see below).
reflexpr-operand can be one of following:
::
|
(1) | ||||||||
type-id | (2) | ||||||||
nested-name-specifier(optional) namespace-name | (3) | ||||||||
id-expression | (4) | ||||||||
( expression )
|
(5) | ||||||||
function-call-expression | (6) | ||||||||
functional-type-conv-expression | (7) | ||||||||
where function-call-expression is
postfix-expression ( expression-list(optional) )
|
|||||||||
and functional-type-conv-expression are following sorts of expressions which perform explict cast:
simple-type-specifier ( expression-list(optional) )
|
(1) | ||||||||
typename-specifier ( expression-list(optional) )
|
(2) | ||||||||
simple-type-specifier braced-init-list | (3) | ||||||||
typename-specifier braced-init-list | (4) | ||||||||
The operand to the reflexpr-specifier shall be a type, namespace, enumerator, variable, data member, function parameter, captured entity, function-call-expression or functional-type-conv-expression, and parenthesized expression. reflexpr(::) reflects the global namespace.
For a reflexpr-operand of form (
expression )
, the expression shall be a (possibly multi-parenthesized) function-call-expression or functional-type-conv-expression.
If an unparenthesized operand can be treated as either a type-id or a functional-type-conv-expression, then it is treated as a type-id. Parenthesizes can be used for disambiguation between function-style cast and a type-id. For example, given a class type X
with default constructor, reflexpr(X()) reflects the function type X(), and reflexpr((X())) reflects the expression X().
If the operand designates both an alias and a class name, the type represented by the reflexpr-specifier reflects the alias and satisfies reflect::Alias
.
If the operand designates a name whose declaration is enclosed in a block scope and the named entity is neither captured nor a function parameter, the program is ill-formed.
[edit] Meta-object types
A meta-object type is an unnamed, incomplete namespace-scope class type. A type satisfies the concept reflect::Object
if and only if it is a meta-object type. Meta-object types may satisfy other concepts, depending on the operand to reflexpr
.
It is unspecified whether repeatedly applying reflexpr
to the same operand yields the same type or a different type. If a meta-object type reflects an incomplete class type, certain type transformations cannot be applied.
A meta-object type allows inspection of some properties of the operand to reflexpr
through type traits or type transformations on it.
[edit] Overload resolution
If the postfix-expression of the function-call-expression is of class type, i.e. e in the function-call-expression e(args) is of class type, then the user-defined conversion function of the type of the postfix-expression (e) shall not be used.
If postfix-expression is not of class type, it shall name a function that is the unique result of overload resolution.
struct Functor { void operator()(int) const; using fptr_t = void(*)(std::nullptr_t); operator fptr_t() const; }; using Meta0 = reflexpr(Functor{}(0)); // OK // using Meta1 = reflexpr(Functor{}(nullptr)); // error: conversion function used
[edit]
An alias is a name introduced by a typedef declaration, an alias-declaration, or a using-declaration.
An entity or alias B
is reflection-related to an entity or alias A
if
-
A
andB
are the same entity or alias, -
A
is a variable or enumerator andB
is the type ofA
, -
A
is an enumeration andB
is the underlying type ofA
, -
A
is a class andB
is a member or base class ofA
, -
A
is a non-template alias that designates the entityB
, -
A
is not the global namespace andB
is an enclosing class or namespace ofA
, -
A
is the parenthesized expression (B
), -
A
is a lambda capture of the closure typeB
, -
A
is the closure type of the lambda captureB
, -
B
is the type specified by the functional-type-conv-expressionA
, -
B
is the function selected by overload resolution for a function-call-expressionA
, -
B
is the return type, a parameter type, or function type of the functionA
, or -
B
is reflection-related to an entity or aliasX
andX
is reflection-related toA
.
Reflection-relation relationship is reflexive and transitive, but not symmetric.
Informally speaking, the case that B
is reflection-related to A
means that B
participates in the declaration or definition of A
.
Zero or more successive applications of type transformations that yield meta-object types to the type denoted by a reflexpr-specifier enable inspection of entities and aliases that are reflection-related to the operand; such a meta-object type is said to reflect the respective reflection-related entity or alias.
struct X; struct B { using X = ::X; typedef X Y; }; struct D : B { using B::Y; }; // ::X, but not B::X or B::Y is reflection-related to D::Y
[edit] Miscellaneous
- An expression used as reflexpr-operand is an unevaluated expressions and potentially constant evaluated.
- For the purpose of determination of variables captured in a lambda expression by a capture-default, a
reflexpr
operand is not considered to be an unevaluated operand. - A function or variable of static storage duration reflected by meta-object type
T
is odr-used by the specialization std::experimental::reflect::get_pointer<T>, as if by taking the address of an id-expression nominating the function or variable. - There can be more than one definition of a meta-object type, as long as all operations on this type yield the same constant expression results.
- A type is dependent if it is denoted by a reflexpr-specifier, and the operand
- is a type-dependent expression or a (possibly parenthesized) functional-type-conv-expression with at least one type-dependent immediate subexpression, or
- designates a dependent type or a member of an unknown specialization or a value-dependent constant expression.
[edit] Keywords
[edit] Predefined feature testing macros
__cpp_reflection (reflection TS) |
a value of at least 201902 indicates that the Reflection TS is supported (macro constant) |
[edit] Library support
[edit] Concepts
Defined in header
<experimental/reflect> | |
Defined in namespace
std::experimental::reflect | |
Defined in inline namespace
std::experimental::reflect::v1 | |
(reflection TS) |
specifies that a type is a meta-object type (concept) |
(reflection TS) |
specifies that a meta-object type is a meta-object sequence type (concept) |
(reflection TS) |
specifies that a meta-object type reflects a template parameter scope (concept) |
(reflection TS) |
specifies that a meta-object type reflects an entity or alias with an associated (possibly empty) name (concept) |
(reflection TS) |
specifies that a meta-object type reflects a type alias, namespace alias, or an alias introduced by a using-declaration (concept) |
(reflection TS) |
specifies that a meta-object type reflects a member-declaration of a class (concept) |
(reflection TS) |
specifies that a meta-object type reflects an enumerator (concept) |
(reflection TS) |
specifies that a meta-object type reflects a variable or data member (concept) |
(reflection TS) |
specifies that a meta-object type satisfies RecordMember , Enumerator , or Variable , or reflects a namespace other than the global namespace (concept) |
(reflection TS) |
specifies that a meta-object type reflects an entity with a type (concept) |
(reflection TS) |
specifies that a meta-object type reflects a namespace (concept) |
(reflection TS) |
specifies that a meta-object type reflects the global namespace (concept) |
(reflection TS) |
specifies that a meta-object type reflects a non-union class type (concept) |
(reflection TS) |
specifies that a meta-object type reflects an enumeration type (concept) |
(reflection TS) |
specifies that a meta-object type reflects a class type (concept) |
(reflection TS) |
specifies that a meta-object type reflects a namespace, class, enumeration, function, closure type, a template parameter scope (concept) |
(reflection TS) |
specifies that a meta-object type reflects a type (concept) |
(reflection TS) |
specifies that a meta-object type reflects an enumerator or a constexpr variable (concept) |
(reflection TS) |
specifies that a meta-object type reflects a direct base class obtained from get_base_classes (concept) |
(reflection TS) |
specifies that a meta-object type reflects a function parameter (concept) |
(reflection TS) |
specifies that a meta-object type reflects a function (including constructors and destructors) (concept) |
(reflection TS) |
specifies that a meta-object type reflects an expression (concept) |
(reflection TS) |
specifies that a meta-object type reflects a parenthesized expression (concept) |
(reflection TS) |
specifies that a meta-object type reflects a function-call-expression (concept) |
(reflection TS) |
specifies that a meta-object type reflects a functional-type-conv-expression (concept) |
(reflection TS) |
specifies that a meta-object type reflects a function (excluding constructors and destructors) (concept) |
(reflection TS) |
specifies that a meta-object type reflects a member function (excluding constructors and destructors) (concept) |
(reflection TS) |
specifies that a meta-object type reflects a special member function (concept) |
(reflection TS) |
specifies that a meta-object type reflects a constructor (concept) |
(reflection TS) |
specifies that a meta-object type reflects a destructor (concept) |
(reflection TS) |
specifies that a meta-object type reflects an operator function or a conversion function (concept) |
(reflection TS) |
specifies that a meta-object type reflects a conversion function (concept) |
(reflection TS) |
specifies that a meta-object type reflects the closure type of a non-generic lambda (concept) |
(reflection TS) |
specifies that a meta-object type reflects a lambda capture (concept) |
[edit] Meta-object operations
Defined in header
<experimental/reflect> | |
Defined in namespace
std::experimental::reflect | |
Defined in inline namespace
std::experimental::reflect::v1 | |
| |
(reflection TS) |
checks if two meta-object types reflect the same entity or alias (class template) |
(reflection TS) |
obtains the presumed line number of the declaration of the reflected entity or alias (class template) |
(reflection TS) |
obtains the implementation-defined column number of the declaration of the reflected entity or alias (class template) |
(reflection TS) |
obtains the presumed file name of the declaration of the reflected entity or alias (class template) |
| |
(reflection TS) |
obtains the size of a meta-object sequence (class template) |
(reflection TS) |
obtains the meta-object type with specified index in a sequence (class template) |
(reflection TS) |
applies a template to the meta-object sequence (class template) |
| |
(reflection TS) |
checks if the reflected entity or alias is unnamed (class template) |
(reflection TS) |
obtains the unqualified name of the reflected entity or alias (class template) |
(reflection TS) |
obtains the implementation-defined display name of the reflected entity or alias (class template) |
| |
(reflection TS) |
obtains the meta-object type reflecting the associated entity of the reflected alias (class template) |
| |
(reflection TS) |
obtains the meta-object type reflecting the type of the reflected entity or alias (class template) |
(reflection TS) |
obtains the type of the reflected entity or alias (class template) |
(reflection TS) |
checks if the meta-object type reflects an enumeration type (class template) |
(reflection TS) |
checks if the meta-object type reflects a union type (class template) |
(reflection TS) |
checks if the meta-object type reflects a non-union class type whose declaration uses class or struct respectively (class template) |
| |
(reflection TS) |
obtains the meta-object type reflecting the scope of the reflected entity or alias (class template) |
| |
(reflection TS) |
obtains the meta-object type reflecting the base class in the given base class relationship (class template) |
| |
(reflection TS) |
checks if the reflected member or base class is public (class template) |
(reflection TS) |
checks if the reflected member or base class is protected (class template) |
(reflection TS) |
checks if the reflected member or base class is private (class template) |
| |
obtains a meta-object sequence type whose elements reflect public, accessible, or all data members of the reflected class (class template) | |
obtains a meta-object sequence type whose elements reflect public, accessible, or all member functions of the reflected class (class template) | |
(reflection TS) |
obtains a meta-object sequence type whose elements reflect all constructors of the reflected class (class template) |
(reflection TS) |
obtains a meta-object sequence type whose elements reflect all operator functions and conversion functions declared in the reflected class (class template) |
(reflection TS) |
obtains the meta-object type reflecting the destructor of the reflected class (class template) |
obtains a meta-object sequence type whose elements reflect public, accessible, or all nested type or member typedefs of the reflected class (class template) | |
obtains a meta-object sequence type whose elements reflect public, accessible, or all base classes of the reflected class (class template) | |
| |
(reflection TS) |
checks whether the reflected enumeration is scoped (class template) |
(reflection TS) |
obtains a meta-object sequence type whose elements reflects the enumerators of the reflected enumeration (class template) |
(reflection TS) |
obtains the meta-object type reflecting the underlying type of the reflected enumeration (class template) |
| |
(reflection TS) |
obtains the value of the reflected variable which is a constant expression (class template) |
(reflection TS) |
checks if the variable is declared with thread_local (class template) |
| |
(reflection TS) |
checks whether the reflected parameter has a default argument (class template) |
| |
(reflection TS) |
obtains a meta-object sequence type whose elements reflects the parameters of the reflected function (class template) |
(reflection TS) |
checks whether the parameter list of the reflected function contains an ellipsis parameter (class template) |
(reflection TS) |
checks whether the reflected function is non-throwing (class template) |
(reflection TS) |
checks whether the reflected function is deleted (class template) |
| |
(reflection TS) |
checks if the reflected variable or function is constexpr (class template) |
| |
(reflection TS) |
checks whether the reflected namespace or function is inline (class template) |
| |
(reflection TS) |
obtains the meta-object type reflecting the unparenthesized expression of the reflected parethesized expression (class template) |
| |
(reflection TS) |
obtains the meta-object type reflecting the function in the reflected function-call-expression (class template) |
| |
(reflection TS) |
obtains the meta-object type reflecting the constructor in reflected functional-type-conv-expression (class template) |
| |
(reflection TS) |
get the address of the reflected variable or function, or the pointer-to-member value to the reflected non-static member (class template) |
| |
checks if the reflected member function is declared with const, volatile, &, or && qualifier respectively (class template) | |
(reflection TS) |
checks if the reflected member function overrides a member function of base class (class template) |
| |
(reflection TS) |
checks if the reflected class or member function is marked with final (class template) |
| |
(reflection TS) |
checks if the reflected variable is of static storage duration, or the reflected member function is static (class template) |
| |
(reflection TS) |
checks if the reflected special member function is implicitly declared (class template) |
(reflection TS) |
checks if the reflected special member function is defaulted in its first declaration (class template) |
| |
(reflection TS) |
checks if the reflected constructor or conversion function is declared with explicit (class template) |
| |
(reflection TS) |
checks if the reflected member function is virtual (class template) |
(reflection TS) |
checks if the reflected member function is pure virtual (class template) |
| |
(reflection TS) |
obtains a meta-object sequence type whose elements reflect the captures of the reflected closure type (class template) |
(reflection TS) |
checks if the capture-default of the lambda expression of the reflected closure type is = or & respectively (class template) |
(reflection TS) |
checks if the operator() of the reflected closure type is declared with const (class template) |
| |
(reflection TS) |
checks if the reflected lambda capture is explicitly captured (class template) |
(reflection TS) |
checks if the reflected lambda capture is an init-capture (class template) |
[edit] Library feature testing macros
Defined in header
<experimental/reflect> | |
__cpp_lib_reflection (reflection TS) |
a value of at least 201902 indicates that the support library of the Reflection TS is supported (macro constant) |
[edit] Satisfaction of concepts
The following table lists that whether a meta-object type reflecting an operand satisfies concepts introduced by the Reflection TS.
Category | reflexpr operands
|
Satisfied concepts |
---|---|---|
Type | class-name designating a union | reflect::Union
|
class-name designating a closure type | reflect::Lambda
| |
class-name designating a non-union class | reflect::Record
| |
enum-name | reflect::Enum
| |
template type-parameter | reflect::Type , reflect::Alias
| |
decltype-specifier | reflect::Type , reflect::Alias
| |
type-name introduced by a using-declaration | reflect::Type , reflect::Alias , reflect::ScopedMember
| |
any other typedef-name | reflect::Type , reflect::Alias
| |
any other type-id | reflect::Type
| |
Namespace | namespace-alias | reflect::Namespace , reflect::Alias
|
the global namespace | reflect::GlobalScope
| |
any other namespace | reflect::Namespace
| |
Expression | the name of a data member | reflect::Variable
|
the name of a variable | reflect::Variable
| |
the name of an enumerator | reflect::Enumerator
| |
the name of a function parameter | reflect::FunctionParameter
| |
the name of a captured entity | reflect::LambdaCapture
| |
parenthesized expression | reflect::ParenthesizedExpression
| |
function-call-expression | reflect::FunctionCallExpression
| |
functional-type-conv-expression | reflect::FunctionalTypeConversion
|
If the operand of the form id-expression is a constant expression, the type specified by the reflexpr-specifier also satisfies reflect::Constant
.
If the reflexpr-operand designates a class member, the type represented by the reflexpr-specifier also satisfies reflect::RecordMember
.
[edit] See also
contains some type’s information, the class returned by the typeid operator (class) | |
(C++11) |
Compile-time type information utilities |