What about a macro to define enums?

オープン
#450 コメント 2 件 リアクション 0 件 担当者 5 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@PhilipFackler がすでに取り組んでいます。

2026年6月12日 から。

評価

この issue はまだ評価されていません。

説明

question

Comments on #440 got me thinking about this (again), especially because we don't want magic_enum to creep into the core code. So I gave it a shot.

Attached is an implementation of a preprocessor macro (most of which I copied from a blog) and some examples. This implements parse, print, and size functions. There's more we could do if everyone is in-favor of the basic approach, but also I would completely understand any resistance. I dislike macros generally, but in this case it seems a good workaround to the limitations on enums in C++.

enum_prop.cpp

Also, try it out here.
https://godbolt.org/z/KvvTT3hv1

主要言語
C++
スター
27
フォーク
11
平均マージ
2日 21時間
マージ済み PR(30日)
15

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

ORNL/GridKit のほかの issue

ORNL/GridKit の issue をすべて見る

似ている issue

C++ の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。