Reflection library (since C++26)
From cppreference.com
The facilities defined in this section support reflective programming, allowing C++ programs to both observe the structure of the program itself and to generate code that depends on those observations.
Core language
The reflection library works in conjunction with two core language features:
Reflection library
| This section is incomplete |
Defined in header
<meta> | |
(C++26) |
the type of reflection values (typedef) |
(C++26) |
exception thrown by reflection functions (class) |
Promoting compile-time storage into static storage | |
(C++26) |
promotes a compile-time string to static storage, returning a reflection representing the static string (function template) |
(C++26) |
promotes compile-time array into static storage, returning a reflection representing the static array (function template) |
(C++26) |
promotes compile-time string to static storage, returning a pointer to the first character of the static string (function template) |
(C++26) |
promotes compile-time array into static storage, returning a span of the static array (function template) |
(C++26) |
promotes compile-time value into static storage, returning a pointer to the static object (function template) |
Operator representations | |
(C++26) |
identifies overloadable operators (enum) |
(C++26) |
identifies the operator represented by the reflection (function) |
(C++26) |
converts a meta::operators enumerator to its symbolic name (function) |
Reflection names and locations | |
(C++26) |
checks if reflection represents an entity that has an identifier (function) |
(C++26) |
if the reflected entity has an identifier, obtains its name (function) |
| obtains a string suitable for identifying the reflected entity (function) | |
(C++26) |
obtains the source location of the reflected entity (function) |
Reflection queries | |
(C++26) |
obtains a reflection of the type of the reflected entity (function) |
(C++26) |
obtains a reflection of the object of the reflected variable (function) |
(C++26) |
obtains a reflection of the constant value of the reflected entity (function) |
| checks if reflection represents a public, protected, or private member or base class (function) | |
(C++26) |
checks if reflection represents a virtual member function or virtual base class (function) |
(C++26) |
checks if reflection represents a pure virtual member function (function) |
(C++26) |
checks if reflection represents a member function that overrides another member function (function) |
(C++26) |
checks if reflection represents a final class or final member function (function) |
(C++26) |
checks if reflection represents a deleted function (function) |
(C++26) |
checks if reflection represents a defaulted function (function) |
(C++26) |
checks if reflection represents a user-provided function (function) |
(C++26) |
checks if reflection represents a user-declared function (function) |
(C++26) |
checks if reflection represents a member function that is declared explicit (function) |
(C++26) |
checks if reflection represents a noexcept function or function type (function) |
(C++26) |
checks if reflection represents a bit-field or a data member description of bit-field (function) |
(C++26) |
checks if reflection represents an enumerator (function) |
(C++26) |
checks if reflection represents an annotation (function) |
(C++26) |
checks if reflection represents a const type or a function type with const qualifier (function) |
(C++26) |
checks if reflection represents a volatile type or a function type with volatile qualifier (function) |
(C++26) |
checks if reflection represents a mutable non-static data member (function) |
| checks if the reflected entity has a storage duration (function) | |
| checks if the reflected entity has a linkage (function) | |
(C++26) |
checks if the reflected entity has "C" language linkage (extern "C") (function) |
(C++26) |
checks if reflection represents a complete type (function) |
(C++26) |
checks if the reflected type has its list of members completely defined (function) |
(C++26) |
checks if reflection represents a variable (function) |
(C++26) |
checks if reflection represents a type (function) |
(C++26) |
checks if reflection represents a namespace (function) |
(C++26) |
checks if reflection represents a type alias (function) |
(C++26) |
checks if reflection represents a namespace alias (function) |
(C++26) |
checks if reflection represents a function (function) |
(C++26) |
checks if reflection represents a function parameter (function) |
(C++26) |
checks if reflection represents an explicit object parameter (function) |
(C++26) |
checks if reflected function parameter has a default argument (function) |
(C++26) |
checks if reflection represents a (scalar) value (function) |
(C++26) |
checks if reflection represents a static object (function) |
(C++26) |
checks if reflection represents a structured binding (function) |
| checks if reflected non-static data member has a default member initializer (function) | |
(C++26) |
checks if the reflected entity is contained in a scope (function) |
(C++26) |
obtains the scope that contains the reflected entity (function) |
(C++26) |
obtains the parameters of the reflected function (function) |
(C++26) |
obtains the variable of the reflected function parameter in the function definition (function) |
(C++26) |
obtains the return type of the reflected function (function) |
Accessibility queries | |
(C++26) |
represents a context for access checking (class) |
(C++26) |
checks if a member is accessible in a given context (function) |
| checks if the reflected class has any inaccessible non-static data members (function) | |
(C++26) |
checks if the reflected class has any inaccessible direct base classes (function) |
(C++26) |
checks if the reflected class has any inaccessible non-static data members or direct base classes (function) |
Scope identification | |
(C++26) |
returns a reflection of the enclosing function (function) |
(C++26) |
returns a reflection of the enclosing class (function) |
(C++26) |
returns a reflection of the enclosing namespace (function) |
Reflection member queries | |
(C++26) |
obtains the accessible direct members of the reflected class or namespace (function) |
(C++26) |
obtains the accessible direct bases of the reflected class (function) |
(C++26) |
obtains the accessible static data members of the reflected class (function) |
(C++26) |
obtains the accessible non-static data members of the reflected class (function) |
(C++26) |
obtains the accessible base class subobjects and non-static data members of the reflected class (function) |
(C++26) |
obtains the enumerators of the reflected enum type (function) |
Reflection layout queries | |
(C++26) |
returns the offset of a (member or base) subobject relative to its enclosing class (function) |
(C++26) |
returns the size in bytes of the reflected object or type (function) |
(C++26) |
returns the alignment of the reflected object or type (function) |
(C++26) |
returns the size in bits of the reflected object or type (function) |
Annotation reflection | |
(C++26) |
obtains the annotations applying to the reflected entity (function) |
(C++26) |
obtains the annotations that apply to the reflected entity and have the specified type (function) |
Value extraction | |
(C++26) |
extracts the value of the reflected entity (function template) |
Reflection substitution | |
(C++26) |
specifies a range of reflection values (concept) |
(C++26) |
checks whether the given arguments can be substituted in the given template (function template) |
(C++26) |
substitutes the given arguments in the given template, and returns a reflection of the result of substitution (function template) |
Expression result reflection | |
(C++26) |
returns a reflection representing a value or template parameter object, suitable for use as a constant template argument (function template) |
(C++26) |
returns a reflection representing an object, suitable for use as a constant template argument (function template) |
(C++26) |
returns a reflection representing a function, suitable for use as a constant template argument (function template) |
Class definition generation | |
(C++26) |
creates a data member description for use with injected declarations (function) |
(C++26) |
checks if reflection represents a data member description (function) |
(C++26) |
defines an aggregate type from a sequence of data member descriptions (function template) |
Primary type categories | |
Composite type categories | |
Type properties | |
Type property queries | |
Type relations | |
Const-volatile modifications | |
Reference modifications | |
Sign modifications | |
Array modifications | |
Pointer modifications | |
Other transformations | |
Checking string literals | |