I'm not sure, but it seems to me that with templates in VS you can only use types with names. For some reason, the VS compiler does not recognize that the enumeration is simply int, even if it does not have a name. This is why test4() without errors and test2() does not.
Edit:
I dig a little decorator and found this answer. So this is not a compiler error. In my opinion, this is a feature because it also checks to see if your code matches the standard ones. In fact, GCC (vesrion 4.3.4, 4.4.5) will not compile this code anyway
test.cpp: In function 'void test2()': test.cpp:34: error: no matching function for call to 'bar(A::<anonymous enum>)' test.cpp:35: error: no matching function for call to 'bar(A::<anonymous enum>)'
but GCC 4.7.3 does not have an error (with `-Wall -Wextra -pedantic) it only reports unused parameters, perhaps C ++ 0x is less structured with respect to unnamed types in templates
Edit2:
I found on the Microsoft Page that VS supports Local and Unnamed types as template arguments , so your code should work. So finally, this is VS error!
source share