std::meta::has_identifier
From cppreference.com
| Defined in header <meta>
|
||
consteval bool has_identifier( std::meta::info r );
|
(since C++26) | |
Determines if what r represents has an associated identifier (including a literal suffix identifier).
Formally:
- If
rrepresents an entity with a typedef name for linkage purposes, returnstrue. - Otherwise, if
rrepresents an unnamed class, enum, variable, bit-field, or namespace, returnsfalse. - Otherwise, if
rrepresents a type alias, returns!std::meta::has_template_arguments(r). - Otherwise, if
rrepresents a type, returnstrueif:
rrepresents a cv-unqualified class type andstd::meta::has_template_arguments(r)isfalse, orrrepresents a cv-unqualified enumeration type.
- Otherwise, if
rrepresents a function, returnstrueifstd::meta::has_template_arguments(r)isfalse, and the function is not a constructor, destructor, operator function, or conversion function. - Otherwise, if
rrepresents a template, returnstrueif the template is not a constructor template, operator function template, or conversion function template. - Otherwise, if
rrepresents a function parameter of a function that is instantiated from a function template, and the parameter is an element of a function parameter pack, returnsfalse. - 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; returnstrueif
- there is a declaration
DinSthat introduces a nameNfor eitherPor the parameter corresponding toPin the templated function thatDdeclares, and - no declaration in
Sdoes so using any name other thanN.
- there is a declaration
void fun(int);
constexpr std::meta::info r = parameters_of(^^fun)[0];
static_assert(!has_identifier(r));
void fun(int x);
static_assert(has_identifier(r));
void fun(int x);
static_assert(has_identifier(r));
void poison() {
void fun(int y);
}
static_assert(!has_identifier(r));
- Otherwise, if
rrepresents a variable, returnsfalseif either the variable corresponds to an element of a function parameter pack, orstd::meta::has_template_arguments(r)istrue, and returnstrueotherwise. - Otherwise, if
rrepresents a structured binding, returnsfalseif the structured binding is an element of a structured binding pack, ortrueotherwise. - Otherwise, if
rrepresents an enumerator, non-static data member, namespace, or namespace alias, returnstrue. - Otherwise, if
rrepresents a direct base class relationship, returnsstd::meta::has_identifier(std::meta::type_of(r)). - Otherwise, if
rrepresents a data member description (T, N, A, W, NUA, ANN), returnstrueif the description's name N is not ⊥. - Otherwise, returns
false.
Parameters
| r | - | a reflection value |
Return value
true if what r represents has an identifier, false otherwise.
Example
| This section is incomplete Reason: no example |
See also
(C++26) |
converts a meta::operators enumerator to its symbolic name (function) |
(C++26) |
if the reflected entity has an identifier, obtains its name (function) |
| obtains a string suitable for identifying the reflected entity (function) |