std::meta::annotations_of_with_type
Defined in header <meta> | ||
|---|---|---|
consteval std::vector<std::meta::info>
annotations_of_with_type( std::meta::info item, std::meta::info type );
| (since C++26) |
Returns the result of std::meta::annotations_of(item) filtered according to the type represented by type.
Parameters
| item | - | a reflection value |
| type | - | a reflection of type or type alias |
Return value
A vector containing each element e in std::meta::annotations_of(item) where std::meta::remove_const(std::meta::type_of(e)) is equal to std::meta::remove_const(type), preserving there order.
Exceptions
Throws std::meta::exception if std::meta::annotations_of(item) would throw, or if
-
std::meta::dealias(type)does not represent a type, or -
std::meta::is_complete_type(type)isfalse.
Example
#include <meta>
struct Option { bool value; };
struct C {
[[=Option{true}]] int a;
[[=Option{false}]] int b;
};
static_assert([:annotations_of_with_type(^^C::a, ^^Option)[0]:].value);
static_assert(![:annotations_of_with_type(^^C::b, ^^Option)[0]:].value);
int main() {}
See also
|
(C++26) | obtains the annotations applying to the reflected entity (function) |
|
(C++26) | checks if reflection represents an annotation (function) |
|
(C++26) | obtains a reflection of the constant value of the reflected entity (function) |
|
(C++26) | determines the type of the reflected entity (function) |
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
https://en.cppreference.com/cpp/meta/annotations_of_with_type