Namespaces
Variants

Reflection library (since C++26)

From cppreference.com
< cpp | meta

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

Template:cpp/meta/dsc is lvalue reference qualifiedTemplate:cpp/meta/dsc is rvalue reference qualifiedTemplate:cpp/meta/dsc is conversion functionTemplate:cpp/meta/dsc is operator functionTemplate:cpp/meta/dsc is literal operatorTemplate:cpp/meta/dsc is special member functionTemplate:cpp/meta/dsc is constructorTemplate:cpp/meta/dsc is default constructorTemplate:cpp/meta/dsc is copy constructorTemplate:cpp/meta/dsc is move constructorTemplate:cpp/meta/dsc is assignmentTemplate:cpp/meta/dsc is copy assignmentTemplate:cpp/meta/dsc is move assignmentTemplate:cpp/meta/dsc is destructorTemplate:cpp/meta/dsc is vararg functionTemplate:cpp/meta/dsc is templateTemplate:cpp/meta/dsc is function templateTemplate:cpp/meta/dsc is variable templateTemplate:cpp/meta/dsc is class templateTemplate:cpp/meta/dsc is alias templateTemplate:cpp/meta/dsc is conversion function templateTemplate:cpp/meta/dsc is operator function templateTemplate:cpp/meta/dsc is literal operator templateTemplate:cpp/meta/dsc is constructor templateTemplate:cpp/meta/dsc is conceptTemplate:cpp/meta/dsc is class memberTemplate:cpp/meta/dsc is namespace memberTemplate:cpp/meta/dsc is nonstatic data memberTemplate:cpp/meta/dsc is static memberTemplate:cpp/meta/dsc is baseTemplate:cpp/meta/dsc dealiasTemplate:cpp/meta/dsc has template argumentsTemplate:cpp/meta/dsc template ofTemplate:cpp/meta/dsc template arguments ofTemplate:cpp/meta/dsc member offsetTemplate:cpp/meta/dsc data member optionsTemplate:cpp/meta/dsc is void typeTemplate:cpp/meta/dsc is null pointer typeTemplate:cpp/meta/dsc is integral typeTemplate:cpp/meta/dsc is floating point typeTemplate:cpp/meta/dsc is array typeTemplate:cpp/meta/dsc is pointer typeTemplate:cpp/meta/dsc is lvalue reference typeTemplate:cpp/meta/dsc is rvalue reference typeTemplate:cpp/meta/dsc is member object pointer typeTemplate:cpp/meta/dsc is member function pointer typeTemplate:cpp/meta/dsc is enum typeTemplate:cpp/meta/dsc is union typeTemplate:cpp/meta/dsc is class typeTemplate:cpp/meta/dsc is function typeTemplate:cpp/meta/dsc is reflection typeTemplate:cpp/meta/dsc is reference typeTemplate:cpp/meta/dsc is arithmetic typeTemplate:cpp/meta/dsc is fundamental typeTemplate:cpp/meta/dsc is object typeTemplate:cpp/meta/dsc is scalar typeTemplate:cpp/meta/dsc is compound typeTemplate:cpp/meta/dsc is member pointer typeTemplate:cpp/meta/dsc is const typeTemplate:cpp/meta/dsc is volatile typeTemplate:cpp/meta/dsc is trivially copyable typeTemplate:cpp/meta/dsc is standard layout typeTemplate:cpp/meta/dsc is empty typeTemplate:cpp/meta/dsc is polymorphic typeTemplate:cpp/meta/dsc is abstract typeTemplate:cpp/meta/dsc is final typeTemplate:cpp/meta/dsc is aggregate typeTemplate:cpp/meta/dsc is structural typeTemplate:cpp/meta/dsc is signed typeTemplate:cpp/meta/dsc is unsigned typeTemplate:cpp/meta/dsc is bounded array typeTemplate:cpp/meta/dsc is unbounded array typeTemplate:cpp/meta/dsc is scoped enum typeTemplate:cpp/meta/dsc is constructible typeTemplate:cpp/meta/dsc is default constructible typeTemplate:cpp/meta/dsc is copy constructible typeTemplate:cpp/meta/dsc is move constructible typeTemplate:cpp/meta/dsc is assignable typeTemplate:cpp/meta/dsc is copy assignable typeTemplate:cpp/meta/dsc is move assignable typeTemplate:cpp/meta/dsc is swappable with typeTemplate:cpp/meta/dsc is swappable typeTemplate:cpp/meta/dsc is destructible typeTemplate:cpp/meta/dsc is trivially constructible typeTemplate:cpp/meta/dsc is trivially default constructible typeTemplate:cpp/meta/dsc is trivially copy constructible typeTemplate:cpp/meta/dsc is trivially move constructible typeTemplate:cpp/meta/dsc is trivially assignable typeTemplate:cpp/meta/dsc is trivially copy assignable typeTemplate:cpp/meta/dsc is trivially move assignable typeTemplate:cpp/meta/dsc is trivially destructible typeTemplate:cpp/meta/dsc is nothrow constructible typeTemplate:cpp/meta/dsc is nothrow default constructible typeTemplate:cpp/meta/dsc is nothrow copy constructible typeTemplate:cpp/meta/dsc is nothrow move constructible typeTemplate:cpp/meta/dsc is nothrow assignable typeTemplate:cpp/meta/dsc is nothrow copy assignable typeTemplate:cpp/meta/dsc is nothrow move assignable typeTemplate:cpp/meta/dsc is nothrow swappable with typeTemplate:cpp/meta/dsc is nothrow swappable typeTemplate:cpp/meta/dsc is nothrow destructible typeTemplate:cpp/meta/dsc is implicit lifetime typeTemplate:cpp/meta/dsc has virtual destructorTemplate:cpp/meta/dsc has unique object representationsTemplate:cpp/meta/dsc reference constructs from temporaryTemplate:cpp/meta/dsc reference converts from temporaryTemplate:cpp/meta/dsc rankTemplate:cpp/meta/dsc extentTemplate:cpp/meta/dsc is same typeTemplate:cpp/meta/dsc is base of typeTemplate:cpp/meta/dsc is virtual base of typeTemplate:cpp/meta/dsc is convertible typeTemplate:cpp/meta/dsc is nothrow convertible typeTemplate:cpp/meta/dsc is layout compatible typeTemplate:cpp/meta/dsc is pointer interconvertible base of typeTemplate:cpp/meta/dsc is invocable typeTemplate:cpp/meta/dsc is invocable r typeTemplate:cpp/meta/dsc is nothrow invocable typeTemplate:cpp/meta/dsc is nothrow invocable r typeTemplate:cpp/meta/dsc remove constTemplate:cpp/meta/dsc remove volatileTemplate:cpp/meta/dsc remove cvTemplate:cpp/meta/dsc add constTemplate:cpp/meta/dsc add volatileTemplate:cpp/meta/dsc add cvTemplate:cpp/meta/dsc remove referenceTemplate:cpp/meta/dsc add lvalue referenceTemplate:cpp/meta/dsc add rvalue referenceTemplate:cpp/meta/dsc make signedTemplate:cpp/meta/dsc make unsignedTemplate:cpp/meta/dsc remove extentTemplate:cpp/meta/dsc remove all extentsTemplate:cpp/meta/dsc remove pointerTemplate:cpp/meta/dsc add pointerTemplate:cpp/meta/dsc remove cvrefTemplate:cpp/meta/dsc decayTemplate:cpp/meta/dsc common typeTemplate:cpp/meta/dsc common referenceTemplate:cpp/meta/dsc underlying typeTemplate:cpp/meta/dsc invoke resultTemplate:cpp/meta/dsc unwrap referenceTemplate:cpp/meta/dsc unwrap ref decayTemplate:cpp/meta/dsc tuple sizeTemplate:cpp/meta/dsc tuple elementTemplate:cpp/meta/dsc is applicable typeTemplate:cpp/meta/dsc is nothrow applicable typeTemplate:cpp/meta/dsc apply resultTemplate:cpp/meta/dsc variant sizeTemplate:cpp/meta/dsc variant alternativeTemplate:cpp/meta/dsc type orderTemplate:cpp/meta/dsc is string literal
Defined in header <meta>
(C++26)
the type of reflection values
(typedef) [edit]
exception thrown by reflection functions
(class) [edit]
Promoting compile-time storage into static storage
promotes a compile-time string to static storage, returning a reflection representing the static string
(function template) [edit]
promotes compile-time array into static storage, returning a reflection representing the static array
(function template) [edit]
promotes compile-time string to static storage, returning a pointer to the first character of the static string
(function template) [edit]
promotes compile-time array into static storage, returning a span of the static array
(function template) [edit]
promotes compile-time value into static storage, returning a pointer to the static object
(function template) [edit]
Operator representations
(C++26)
identifies overloadable operators
(enum) [edit]
identifies the operator represented by the reflection
(function) [edit]
converts a meta::operators enumerator to its symbolic name
(function) [edit]
Reflection names and locations
checks if reflection represents an entity that has an identifier
(function) [edit]
if the reflected entity has an identifier, obtains its name
(function) [edit]
obtains a string suitable for identifying the reflected entity
(function) [edit]
obtains the source location of the reflected entity
(function) [edit]
Reflection queries
(C++26)
obtains a reflection of the type of the reflected entity
(function) [edit]
(C++26)
obtains a reflection of the object of the reflected variable
(function) [edit]
obtains a reflection of the constant value of the reflected entity
(function) [edit]
checks if reflection represents a public, protected, or private member or base class
(function) [edit]
checks if reflection represents a virtual member function or virtual base class
(function) [edit]
checks if reflection represents a pure virtual member function
(function) [edit]
checks if reflection represents a member function that overrides another member function
(function) [edit]
(C++26)
checks if reflection represents a final class or final member function
(function) [edit]
checks if reflection represents a deleted function
(function) [edit]
checks if reflection represents a defaulted function
(function) [edit]
checks if reflection represents a user-provided function
(function) [edit]
checks if reflection represents a user-declared function
(function) [edit]
checks if reflection represents a member function that is declared explicit
(function) [edit]
checks if reflection represents a noexcept function or function type
(function) [edit]
checks if reflection represents a bit-field or a data member description of bit-field
(function) [edit]
checks if reflection represents an enumerator
(function) [edit]
checks if reflection represents an annotation
(function) [edit]
(C++26)
checks if reflection represents a const type or a function type with const qualifier
(function) [edit]
checks if reflection represents a volatile type or a function type with volatile qualifier
(function) [edit]
checks if reflection represents a mutable non-static data member
(function) [edit]
checks if the reflected entity has a storage duration
(function) [edit]
checks if the reflected entity has a linkage
(function) [edit]
checks if the reflected entity has "C" language linkage (extern "C")
(function) [edit]
checks if reflection represents a complete type
(function) [edit]
checks if the reflected type has its list of members completely defined
(function) [edit]
checks if reflection represents a variable
(function) [edit]
(C++26)
checks if reflection represents a type
(function) [edit]
checks if reflection represents a namespace
(function) [edit]
checks if reflection represents a type alias
(function) [edit]
checks if reflection represents a namespace alias
(function) [edit]
checks if reflection represents a function
(function) [edit]
checks if reflection represents a function parameter
(function) [edit]
checks if reflection represents an explicit object parameter
(function) [edit]
checks if reflected function parameter has a default argument
(function) [edit]
(C++26)
checks if reflection represents a (scalar) value
(function) [edit]
(C++26)
checks if reflection represents a static object
(function) [edit]
checks if reflection represents a structured binding
(function) [edit]
checks if reflected non-static data member has a default member initializer
(function) [edit]
checks if the reflected entity is contained in a scope
(function) [edit]
(C++26)
obtains the scope that contains the reflected entity
(function) [edit]
obtains the parameters of the reflected function
(function) [edit]
obtains the variable of the reflected function parameter in the function definition
(function) [edit]
obtains the return type of the reflected function
(function) [edit]
Accessibility queries
represents a context for access checking
(class) [edit]
checks if a member is accessible in a given context
(function) [edit]
checks if the reflected class has any inaccessible non-static data members
(function) [edit]
checks if the reflected class has any inaccessible direct base classes
(function) [edit]
checks if the reflected class has any inaccessible non-static data members or direct base classes
(function) [edit]
Scope identification
returns a reflection of the enclosing function
(function) [edit]
returns a reflection of the enclosing class
(function) [edit]
returns a reflection of the enclosing namespace
(function) [edit]
Reflection member queries
obtains the accessible direct members of the reflected class or namespace
(function) [edit]
(C++26)
obtains the accessible direct bases of the reflected class
(function) [edit]
obtains the accessible static data members of the reflected class
(function) [edit]
obtains the accessible non-static data members of the reflected class
(function) [edit]
obtains the accessible base class subobjects and non-static data members of the reflected class
(function) [edit]
obtains the enumerators of the reflected enum type
(function) [edit]
Reflection layout queries
(C++26)
returns the offset of a (member or base) subobject relative to its enclosing class
(function) [edit]
(C++26)
returns the size in bytes of the reflected object or type
(function) [edit]
returns the alignment of the reflected object or type
(function) [edit]
returns the size in bits of the reflected object or type
(function) [edit]
Annotation reflection
obtains the annotations applying to the reflected entity
(function) [edit]
obtains the annotations that apply to the reflected entity and have the specified type
(function) [edit]
Value extraction
(C++26)
extracts the value of the reflected entity
(function template) [edit]
Reflection substitution
specifies a range of reflection values
(concept) [edit]
checks whether the given arguments can be substituted in the given template
(function template) [edit]
substitutes the given arguments in the given template, and returns a reflection of the result of substitution
(function template) [edit]
Expression result reflection
returns a reflection representing a value or template parameter object, suitable for use as a constant template argument
(function template) [edit]
returns a reflection representing an object, suitable for use as a constant template argument
(function template) [edit]
returns a reflection representing a function, suitable for use as a constant template argument
(function template) [edit]
Class definition generation
creates a data member description for use with injected declarations
(function) [edit]
checks if reflection represents a data member description
(function) [edit]
defines an aggregate type from a sequence of data member descriptions
(function template) [edit]
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