Namespaces
Variants

std::meta::type_of

From cppreference.com
< cpp | meta
Defined in header <meta>
consteval std::meta::info type_of( std::meta::info r );
(since C++26)

Returns a reflection representing the type of what r represents.

Formally:

  • If r represents a function parameter (see std::meta::parameters_of), returns a reflection of the corresponding type in the parameter-type-list of the function.
  • If r represents a value, object, variable, function, non-static data member, or unnamed bit-field, returns a reflection of the type of what r represents.
  • If r represents an annotation, returns std::meta::type_of(std::meta::constant_of(r)).
  • If r represents an enumerator of an enumeration type E :
  • if type_of is called after E 's definition, returns a reflection of E ;
  • otherwise (type_of is called within E 's definition), returns a reflection of an integer type (which is the type of the enumerator within the enumeration definition).
  • If r represents a direct base class relationship (i.e. an element of std::meta::bases_of(x, ctx)), returns a reflection of the base class in the relationship.
  • If r represents a data member description (i.e. a value returned by std::meta::data_member_spec), returns a reflection of the type in the description.

Parameters

r - a reflection of something that has a type

Return value

The type of what r represents.

Exceptions

Throws std::meta::exception unless what r represents has a type. That is, r must represent one of:

  • value
  • annotation
  • object
  • variable
  • function whose type does not contain an undeduced placeholder type and that is not a constructor or destructor
  • enumerator
  • non-static data member
  • unnamed bit-field
  • direct base class relationship
  • data member description
  • function parameter

Example

See also