最終更新日時(UTC):
が更新

履歴 編集

function
<meta>

std::meta::nonstatic_data_members_of(C++26)

namespace std::meta {
  consteval std::vector<info> nonstatic_data_members_of(info type, access_context ctx);
}

概要

クラスのメンバ変数のリフレクションを取得する。

戻り値

type完全型のクラスを表す場合、アクセスコンテキストctxでアクセス可能なメンバ変数のリフレクションを宣言順に格納したvectorを返す。

例外

r完全型のクラスを表さない場合、std::meta::exception例外を送出する。

#include <meta>
#include <print>

struct Point {
  int x;
  int y;
};

int main() {
  Point p{10, 20};
  template for (constexpr auto m :
      std::define_static_array(std::meta::nonstatic_data_members_of(^^Point,
          std::meta::access_context::unchecked()))) {
    std::println("{} = {}", std::meta::identifier_of(m), p.[:m:]);
  }
}

出力

x = 10
y = 20

バージョン

言語

  • C++26

処理系

関連項目

参照