From cppreference.com
template<classT>constevalTextract(std::meta::infor);(since C++26)Extracts the value of what r represents as a value of type T.
Let UT be std::remove_cv_t<T>. The result is determined as follows:
If T is a reference type:
If r represents an object, returns a reference to that object.
Otherwise, r must represent a variable, returns a reference to the object of the variable.
Otherwise, if r represents a non-static data member or a function:
If UT is a pointer type, returns a pointer to the function represented by r.
Otherwise, UT must be a pointer-to-member type, returns a pointer-to-member value designating the entity represented by r.
Otherwise:
returns static_cast<UT>([:R:]) where R is a constant expression equal to std::meta::constant_of(r).
The type T and the type of what r represents can differ only in limited ways. See the
section for details.
Template parameters
T - the type of return value Parameters
r - a reflection value Return value
The value of what r represents, as described above.
Exceptions
Throws
unless:
If T is a reference type, all of the following conditions are met:
r represents a variable or object.
Let RT be the type of the entity represented by r. Values of type RT can be converted to T via only
.
If r represents a variable, then either that variable is usable in constant expressions or its lifetime began within the core constant expression currently under evaluation.
Otherwise, if r represents a non-static data member or a function:
If r represents a non-static data member with type X that is a direct member of a class C:
The member is not a bit-field, UT and X C::* are
, and std::is_convertible_v<XC::*,UT> is true.
If r represents an implicit object member function with type F that is a direct member of a class C:
Values of type F C::* can be converted to UT via only
.
Otherwise, r represents a non-member function, static member function, or explicit object member function of function type F:
Values of type F* can be converted to UT via only
.
Otherwise, all the following conditions are met:
The expression std::meta::constant_of(r) does not throw.
Let RT be the type of the entity represented by std::meta::constant_of(r), any of the following conditions is met:
RT is a pointer type, UT and RT are either
or both function pointer types, and std::is_convertible_v<RT,UT> is true.
RT is not a pointer type, and the cv-unqualified types of UT and RT are the same.
RT is an array type, UT is a pointer type, std::remove_extent_t<RT>* and UT are similar types, and the value represented by std::meta::constant_of(r) is convertible to UT.
RT is a
, UT is a function pointer type, and the value represented by std::meta::constant_of(r) is convertible to UT.
Example
See also