std::meta::annotations_of_with_type
From cppreference.com
| 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, orstd::meta::is_complete_type(type)isfalse.
Example
Run this code
#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) |
obtains a reflection of the type of the reflected entity (function) |