Type-Enum

Run Settings
LanguageC++
Language Version
Run Command
#include <iostream> #include <cstring> using namespace std; #define ENUM_VALUE(category, type) \ struct type { \ static inline const char* category() {\ return #type; \ } \ } #define ENUM_TYPE(category, type) static inline const char* category() { \ return #type; \ } ENUM_VALUE( hello ); struct S { int a; // float c; }; S s; int a; // static_assert(sizeof s == sizeof a, ""); // memcpy(&a, &s, sizeof a); int main() { cout << hello::value(); return 0; }
Editor Settings
Theme
Key bindings
Full width
Lines