We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b38b2e0 commit 9255b9cCopy full SHA for 9255b9c
repl/test2.mtc
@@ -0,0 +1,22 @@
1
+enum E { one, two, three };
2
+
3
+const char* EnumToString(auto enumValue)
4
+{
5
+ const char* result = cast(const char*) 0;
6
7
+ switch(enumValue)
8
+ {
9
+ @run {
10
+ type enumType = .Compiler->GetType(.Compiler, enumValue);
11
+ metac_enum_members_t* members = .Compiler->GetEnumMembers(.Compiler, enumType);
12
+ for(uint32_t i = 0; i < members->Count; i++)
13
14
+ eject case $(members->Names[i]):
15
+ result = #$(members->Names[i]);
16
+ }
17
+ };
18
19
+ return result;
20
+}
21
22
+@run { assert(0 == strcmp(EnumToString(E.two), "two")); };
0 commit comments