Namespaces
Variants

std::meta::annotations_of_with_type

From cppreference.com
< cpp | meta
 
 
 
Reflection library
 
Reflection types and queries
Reflection queries
Reflection layout queries
Type properties
Type property queries
 
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) is false.

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

obtains the annotations applying to the reflected entity
(function) [edit]
checks if reflection represents an annotation
(function) [edit]
obtains a reflection of the constant value of the reflected entity
(function) [edit]
(C++26)
obtains a reflection of the type of the reflected entity
(function) [edit]