namespace std::meta {
consteval string_view identifier_of(info r);
consteval u8string_view u8identifier_of(info r);
}
概要
リフレクションの識別子を文字列で取得する。
戻り値
rの識別子を返す。has_identifier(r)がtrueであり、識別子が返す文字エンコーディングで表現可能であることが事前条件となる。
例外
has_identifier(r)がfalseの場合、または返される識別子が文字エンコーディングで表現できない場合、std::meta::exception例外を送出する。
例
#include <meta>
#include <print>
struct Point {
int x;
int y;
};
int main() {
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));
}
}
出力
x
y
バージョン
言語
- C++26
処理系
- Clang: ??
- GCC: 16 (
-freflectionオプション指定) ✅ - Visual C++: ??