- meta[meta header]
- std::meta[meta namespace]
- function[meta id-type]
- cpp26[meta cpp]
namespace std::meta {
consteval std::vector<info> static_data_members_of(info type, access_context ctx);
}- info[link info.md]
- access_context[link access_context.md]
クラスの静的データメンバのリフレクションを取得する。
typeが完全型のクラスを表す場合、アクセスコンテキストctxでアクセス可能な静的データメンバのリフレクションを格納したvectorを返す。
rが完全型のクラスを表さない場合、std::meta::exception例外を送出する。
#include <meta>
#include <print>
struct S {
static int count;
static constexpr double pi = 3.14;
int instance_var;
};
int main() {
static constexpr auto statics = std::define_static_array(
std::meta::static_data_members_of(
^^S, std::meta::access_context::unchecked()));
static_assert(statics.size() == 2);
template for (constexpr auto m : statics) {
std::println("{}", std::meta::identifier_of(m));
}
}- std::meta::access_context[link access_context.md]
- unchecked[link access_context/unchecked.md]
- std::meta::identifier_of[link identifier_of.md]
count
pi
- C++26
- Clang: ??
- GCC: 16 (
-freflectionオプション指定) [mark verified] - Visual C++: ??