Namespaces
Variants

std::meta::identifier_of, std::meta::u8identifier_of

From cppreference.com
< cpp | meta
 
 
 
Reflection library
 
Defined in header <meta>
consteval std::string_view identifier_of( std::meta::info r );
(1) (since C++26)
consteval std::u8string_view u8identifier_of( std::meta::info r );
(2) (since C++26)

Returns the identifier associated with what r represents.

1) The result is a character string encoded in the ordinary literal encoding.
2) The result is a UTF-8 string.

The result string is determined as follows:

  • If r represents an entity with a typedef name for linkage purposes, returns that name.
  • Otherwise, if r represents a literal operator or literal operator template, returns its literal suffix identifier.
  • Otherwise, if r represents a function parameter P of a function F, then let S be the set of declarations, ignoring any explicit instantiations, that are reachable from a point in the evaluation context and that declare either F or a templated function of which F is a specialization, returns the name that was introduced by a declaration in S for the parameter corresponding to P.
  • Otherwise, if r represents an entity, returns its declared name.
  • Otherwise, if r represents a direct base class relationship, returns std::meta::identifier_of(std::meta::type_of(r)) or std::meta::u8identifier_of(std::meta::type_of(r)).
  • Otherwise, if r represents a data member description (T, N, A, W, NUA, ANN), returns the description's name N.

Parameters

r - a reflection value

Return value

The identifier of what r represents, as described above.

Exceptions

Throws std::meta::exception unless std::meta::has_identifier(r) is true and the result string is representable in the corresponding encoding.

Notes

The result V is null-terminated: V.data()[V.size()] is guaranteed to be '\0'. Each element in V is a potentially non-unique object with static storage duration that is usable in constant expressions; a pointer to such an element is not suitable for use as a template argument for a non-type template parameter of pointer type.

Example

See also

checks if reflection represents an entity that has an identifier
(function) [edit]