Overview
ISO/IEC TS 23619:2021 - Information technology - C++ extensions for reflection defines a set of experimental language and library extensions that add static reflection capabilities to C++. The Technical Specification extends ISO/IEC 14882:2020 by introducing new syntactic forms, a reflexpr keyword and a reflexpr-specifier that yield meta-object types. It also specifies a library header, ****, feature-test macros, and namespace conventions for the experimental reflection facilities.
Key topics and requirements
- Language extensions
- Addition of the reflexpr keyword and a new simple-type-specifier form:
reflexpr(reflexpr-operand).
- The reflexpr-operand may be a type, namespace, enumerator, variable, data member, function parameter, captured entity, parenthesized expression, function-call-expression, or functional-type-conv-expression.
- Changes to lexical and grammar rules (e.g., primary/postfix expressions, lambda capture semantics) to accommodate reflection.
- Meta-object types
reflexpr(x) yields an unnamed, incomplete namespace‑scope class type that satisfies reflect::Object and other reflect concepts, enabling compile‑time inspection of the operand and entities that are reflection‑related.
- The specification defines how reflection‑relatedness is computed (reflexive, transitive relationships such as aliases, members, bases, and selected overloads).
- Library and feature-test macros
- Header: **** (contents imported into
std::experimental::reflect::v1).
- Feature-test macros: __cpp_reflection (201902) and __cpp_lib_reflection (201902).
- Library components include static reflection utilities (Clause 21.11) and named utilities referenced in the TS (for example, transformations like
get_aliased_t, get_reflected_type_t, get_base_classes_t, and functions that may odr-use static storage such as get_pointer).
- Conformance and documentation
- Changes are intended as modifications to ISO/IEC 14882:2020; editorial diffs in the TS use underlining/strikethrough to indicate additions/deletions.
Applications and users
- Who uses this TS
- Compiler implementers and C++ toolchain vendors integrating static reflection.
- Library authors and framework developers creating generic metaprogramming utilities.
- Developers of code generators, serializers, ORM layers, unit-test frameworks, and static analyzers that benefit from compile‑time introspection.
- Practical uses
- Compile‑time introspection of types, members, aliases and overload resolution.
- Metaprogramming patterns that generate or adapt code based on reflected information.
- Safer and more expressive serialization, binding, dependency injection, and code instrumentation implemented at compile time.
Related standards
- ISO/IEC 14882:2020 - Programming Languages - C++ (base language standard).
- ISO/IEC TS 19217:2015 - C++ Extensions for Concepts (compatibility and influence noted in the TS).
Keywords: ISO/IEC TS 23619:2021, C++ reflection, reflexpr, meta-object type, std::experimental::reflect, , static reflection, feature-test macros, C++ metaprogramming.