This compiles on GCC 4.6 but doesn’t with VS2010 sp1:
Is it my fault or VS screwed up again?
#include "stdafx.h"
enum Attribute{red_att,black_att,key_att,value_att};
struct Color{};
template<enum Attribute>
struct Tag_Value;
template<>
struct Tag_Value<red_att>
{
typedef Color type;
};
int main()
{
return 0;
}
Errors:
error C2599: 'Attribute' : forward declaration of enum type is not allowed
error C2440: 'specialization' : cannot convert from 'Attribute' to 'Attribute'
I’m not certain what the exact problem is—my guess is that it is treating
enum Attributeas the beginning of a new enum declaration… perhaps as a member of Tag_Value. So you have twoAttributeenums and it won’t let you specialize one with the other.To fix, just get rid of the
enum:to this: