namespace std::meta {
consteval std::vector<info> enumerators_of(info type_enum);
}
概要
列挙型の列挙子のリフレクションを取得する。
戻り値
type_enumが列挙型を表す場合、そのすべての列挙子のリフレクションを宣言順に格納したstd::vectorオブジェクトを返す。
例外
rが列挙型を表さない場合、std::meta::exception例外を送出する。
例
#include <meta>
#include <print>
enum class Color { red, green, blue };
int main() {
template for (constexpr auto e : std::define_static_array(std::meta::enumerators_of(^^Color))) {
std::println("{}", std::meta::identifier_of(e));
}
}
出力
red
green
blue
バージョン
言語
- C++26
処理系
- Clang: ??
- GCC: 16 (
-freflectionオプション指定) ✅ - Visual C++: ??