Skip to content

Latest commit

 

History

History
59 lines (43 loc) · 1.22 KB

File metadata and controls

59 lines (43 loc) · 1.22 KB

enumerators_of

  • 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

処理系

参照