I'm using the Microsoft Visual Studio 2019 compiler (cl.exe), and it is rejecting some code accepted by both Clang and GCC, related to using enums as template parameters, where the templates are specialized for particular enum values.
enum Foo {
Bar,
Baz
};
template<enum Foo = Bar> class Clazz {
};
template<> class Clazz<Baz> {
};
The VC++ compiler reports several errors on the template specialization:
<source>(10): error C2440: 'specialization': cannot convert from 'Foo' to 'Foo'
<source>(10): note: Conversion to enumeration type requires an explicit cast (static_cast, C-style cast or function-style cast)
This code is accepted without errors by both Clang and GCC. Is this a bug with VC++?
Replacing the 'enum Foo' in the template declaration with just 'int' causes the errors to go away. However, this is not an acceptable answer, as I'm trying to port a large code base over to VC++.