Namespaces
Variants

std::meta::annotations_of_with_type

提供元 ja.cppreference.net
< cpp | meta
 
 
 
リフレクションライブラリ
 
リフレクションの型とクエリ
リフレクションクエリ
リフレクションレイアウトクエリ
型プロパティ
型プロパティクエリ
 
ヘッダ <meta>
consteval std::vector<std::meta::info>
    annotations_of_with_type( std::meta::info item, std::meta::info type );
(C++26 以上) で定義

std::meta::annotations_of(item) の結果を、type が表す型に従ってフィルタリングして返します。

引数

item - リフレクション値
type - 型または型エイリアスのリフレクション

戻り値

e における各要素 std::meta::annotations_of(item) のうち、std::meta::remove_const(std::meta::type_of(e)) が std::meta::remove_const(type) と等しいものを、元の順序を保持して含むベクトル。

例外

std::meta::exception を投げます。ただし、std::meta::annotations_of(item) が例外を投げる場合、または

  • std::meta::dealias(type) が型を表していない場合、あるいは
  • std::meta::is_complete_type(type) が false である場合。

例

#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() {}

関連項目

リフレクションされたエンティティに適用されるアノテーションを取得する
(関数)
リフレクションが アノテーション
を表すかどうかを調べる (関数)
リフレクションされたエンティティの定数値のリフレクションを取得する
(関数)
(C++26)
リフレクションされたエンティティの型のリフレクションを取得する
(関数)