std::meta::identifier_of, std::meta::u8identifier_of
From cppreference.com
| 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
rrepresents an entity with a typedef name for linkage purposes, returns that name. - Otherwise, if
rrepresents a literal operator or literal operator template, returns its literal suffix identifier. - Otherwise, if
rrepresents a function parameterPof a functionF, then letSbe the set of declarations, ignoring any explicit instantiations, that are reachable from a point in the evaluation context and that declare eitherFor a templated function of whichFis a specialization, returns the name that was introduced by a declaration inSfor the parameter corresponding toP. - Otherwise, if
rrepresents an entity, returns its declared name. - Otherwise, if
rrepresents a direct base class relationship, returnsstd::meta::identifier_of(std::meta::type_of(r))orstd::meta::u8identifier_of(std::meta::type_of(r)). - Otherwise, if
rrepresents 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
| This section is incomplete Reason: no example |
See also
(C++26) |
checks if reflection represents an entity that has an identifier (function) |