- meta[meta header]
- std::meta[meta namespace]
- function[meta id-type]
- cpp26[meta cpp]
namespace std::meta {
consteval std::vector<info> enumerators_of(info type_enum);
}- info[link info.md]
列挙型の列挙子のリフレクションを取得する。
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オプション指定) [mark verified] - Visual C++: ??