Namespaces
Variants

Reflection library (since C++26)

From cppreference.com
< cpp | meta
 
 
 
Reflection library
 
Reflection types and queries
Reflection queries
Reflection layout queries
Type properties
Type property queries
 

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

Types

Defined in header <meta>
(C++26)
the type of reflection values
(typedef) [edit]
exception thrown by reflection functions
(class) [edit]
a context for access checking
(class) [edit]
data member options including name, alignment, and bit width
(class) [edit]
the offset of a member or base class relative to its enclosing class
(class) [edit]
(C++26)
constants that identify overloadable operators
(enum) [edit]

Concepts

Defined in header <meta>
specifies a range of reflection values
(concept) [edit]

Functions

Defined in header <meta>
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)
constants that identify 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)
determines 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 is a ref qualified member function
(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 conversion function
(function) [edit]
checks if reflection represents an operator overload
(function) [edit]
checks if reflection represents a user-defined literal operator
(function) [edit]
checks if reflection represents a special member function
(function) [edit]
checks if the reflected entity is a constructor of this kind
(function) [edit]
checks if the reflected entity is an assignment operator of this kind
(function) [edit]
checks if the reflected entity is a destructor
(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]
checks if reflection represents a function or function type with an ellipsis parameter
(function) [edit]
checks if reflected entity is a template
(function) [edit]
checks if reflected entity is a function template
(function) [edit]
checks if reflected entity is a variable template
(function) [edit]
checks if reflected entity is a class template
(function) [edit]
checks if reflected entity is a alias template
(function) [edit]
checks if reflected entity is a conversion function template
(function) [edit]
checks if reflected entity is an operator function template
(function) [edit]
checks if reflected entity is a literal operator template
(function) [edit]
checks if reflected entity is a constructor template
(function) [edit]
checks if reflection represents a concept
(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 reflection represents a class member
(function) [edit]
checks if reflection represents a namespace member
(function) [edit]
checks if reflection represents a non-static data member
(function) [edit]
checks if reflection represents a static class member
(function) [edit]
(C++26)
checks if reflection represents a direct base class relationship
(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]
(C++26)
determines the underlying entity of the reflected type/namespace alias
(function) [edit]
checks if reflected entity is produced by substituting template arguments into a template
(function) [edit]
determines the template used to instantiate the reflected entity
(function) [edit]
obtains the template arguments of 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
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
checks whether the reflected arguments can be substituted in the reflected template
(function template) [edit]
substitutes reflected arguments in the reflected template
(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
checks if reflected type is void
(function) [edit]
checks if reflected type is std::nullptr_t
(function) [edit]
checks if reflected type is an integral type
(function) [edit]
checks if reflected type is a floating-point type
(function) [edit]
checks if reflected type is an array type
(function) [edit]
checks if reflected type is a pointer type
(function) [edit]
checks if reflection represents an lvalue reference
(function) [edit]
checks if reflection represents an rvalue reference
(function) [edit]
checks if reflection represents a member object pointer type
(function) [edit]
checks if reflection represents a member function pointer type
(function) [edit]
checks if reflected type is an enumeration type
(function) [edit]
checks if reflected type is a union type
(function) [edit]
checks if reflected type is a non-union class type
(function) [edit]
checks if reflected type is a function type
(function) [edit]
checks if reflected type is std::meta::info
(function) [edit]
Composite type categories
checks if reflection represents either an lvalue reference or rvalue reference
(function) [edit]
checks if reflection represents an arithmetic type
(function) [edit]
checks if reflection represents a fundamental type
(function) [edit]
checks if reflected type is an object type
(function) [edit]
checks if reflected type is a scalar type
(function) [edit]
checks if reflected type is a compound type
(function) [edit]
checks if reflection represents a member pointer type
(function) [edit]
Type properties
checks if reflection represents a const-qualified type
(function) [edit]
checks if reflection represents a volatile-qualified type
(function) [edit]
checks if reflection represents a trivially copyable type
(function) [edit]
checks if reflected type is a standard-layout type
(function) [edit]
checks if reflected type is a class (but not union) type and has no non-static data members
(function) [edit]
checks if reflected type is a polymorphic class type
(function) [edit]
checks if reflected type is an abstract class type
(function) [edit]
checks if reflected type is a final class type
(function) [edit]
checks if reflected type is an aggregate type
(function) [edit]
checks if reflected type is a structural type
(function) [edit]
checks if reflection represents a signed arithmetic type
(function) [edit]
checks if reflection represents an unsigned arithmetic type
(function) [edit]
checks if reflection represents an array type of known bound
(function) [edit]
checks if reflection represents an array type of unknown bound
(function) [edit]
checks if reflection represents a scoped enumeration type
(function) [edit]
checks if reflected type has a constructor for specific arguments
(function template) [edit]
checks if reflected type has a default constructor
(function) [edit]
checks if reflected type has a copy constructor
(function) [edit]
checks if reflected type can be constructed from an rvalue reference
(function) [edit]
checks if reflected type has an assignment operator for a specific argument
(function) [edit]
checks if reflected type has a copy assignment operator
(function) [edit]
checks if reflected type has a move assignment operator
(function) [edit]
checks if objects of one reflected type can be swapped with objects of same or different other reflected type
(function) [edit]
checks if reflected type has a non-deleted destructor
(function) [edit]
checks if reflected type is an implicit-lifetime type
(function) [edit]
checks if reflected type has a virtual destructor
(function) [edit]
checks if every bit in reflected type's object representation contributes to its value
(function) [edit]
checks if a reference is bound to a temporary in direct-initialization
(function) [edit]
checks if a reference is bound to a temporary in copy-initialization
(function) [edit]
Type property queries
(C++26)
obtains the number of dimensions of reflected array type
(function) [edit]
(C++26)
obtains the size of reflected array type along a specified dimension
(function) [edit]
Type relations
checks if two reflections represent the same types
(function) [edit]
checks if two reflections represent types such that one type is a base of the other type
(function) [edit]
checks if two reflections represent types such that one type is a virtual base of the other type
(function) [edit]
checks if reflected type can be converted to the other type
(function) [edit]
checks if two reflections represent layout-compatible types
(function) [edit]
checks if reflected type is a pointer-interconvertible base of another type
(function) [edit]
checks if the reflected type can be invoked (as if by std::invoke) with the given argument types
(function template) [edit]
Const-volatile modifications
removes const and/or volatile specifiers from reflected type
(function) [edit]
adds const and/or volatile specifiers to reflected type
(function) [edit]
Reference modifications
removes a reference from reflected type
(function) [edit]
adds an lvalue or rvalue reference to reflected type
(function) [edit]
Sign modifications
obtains the corresponding signed type for reflected integral type
(function) [edit]
obtains the corresponding unsigned type for reflected integral type
(function) [edit]
Array modifications
removes one extent from reflected array type
(function) [edit]
removes all extents from reflected array type
(function) [edit]
Pointer modifications
removes a pointer from reflected type
(function) [edit]
adds a pointer to reflected type
(function) [edit]
Other transformations
combines meta::remove_cv and meta::remove_reference
(function) [edit]
(C++26)
applies type transformations as when passing a function argument by value
(function) [edit]
determines the common type of a sequence of reflected types
(function template) [edit]
determines the common reference type of a sequence of reflected types
(function template) [edit]
obtains the underlying integer type for reflected enumeration type
(function) [edit]
deduces the result type of invoking a callable object with a set of arguments
(function template) [edit]
get the reference type wrapped in std::reference_wrapper
(function) [edit]
obtains the size of reflected tuple
(function) [edit]
obtains the type of the specified element of reflected tuple
(function) [edit]
checks if the callable object can be invoked (as if by std::invoke) with a tuple of arguments
(function) [edit]
deduces the result type of invoking a callable object with a tuple of arguments
(function) [edit]
obtains the size of reflected variant's list of alternatives
(function) [edit]
obtains the type of reflected tuple's alternative specified by its index
(function) [edit]
performs three-way comparison on reflected types
(function) [edit]
Checking string literals
checks if a pointer points into a string literal
(function) [edit]

Notes

Feature-test macro Value Std Feature
__cpp_lib_reflection 202506L (C++26) <meta>: Reflection library support.
Constexpr exceptions as error handling in reflection.

Example

Morty Proxy This is a proxified and sanitized view of the page, visit original site.