Why is this code not compiling and what can I do to compile it?
#include <iostream> using namespace std; enum class myEnum : unsigned int { bar = 3 }; int main() { // your code goes here unsigned int v = 2; switch(v) { case 2: break; case myEnum::bar: break; } return 0; }
ideone:
https://ideone.com/jTnVGq
prog.cpp: In function 'int main()': prog.cpp:18:16: error: could not convert 'bar' from 'myEnum' to 'unsigned int' case myEnum::bar:
Cannot build in GCC and Clang, works in MSVC 2013.
paulm source share