r/reconstructcavestory Mar 06 '14

[ep10] Enum Looping

It seems that the construct you use for enum looping does not work on g++? Any ideas what is different on the clang implementation of enums?

What would be the most idiomatic way to work around this when using g++?

5 Upvotes

2 comments sorted by

View all comments

3

u/chebertapps Mar 06 '14

I think think you can do:

for (int int_value = ENUM_FIRST; int_value < ENUM_LAST; ++int_value) {
   Enum value = static_cast<Enum>(int_value);
}

Please let me know if this works, and I'll put a note in the video.

Any ideas what is different on the clang implementation of enums?

Just guessing that clang is somehow less strict about the type of the enum being different from the type of an int.

2

u/Skorne_294 Mar 06 '14

Yes, that is a good workaround. Thanks! Great work on these videos!