I\'m looking for a hacky kind of solution to the following problem: GCC 4.4+ accepts the following c++0x code:
enum class my_enum
{
value1,
value2
};
Do not use this solution. See the accepted answer by Howard for a better solution. I'm leaving this post here because Howard's answer refers to it.
If you need to be able to compile your code with a compiler that doesn't yet support a new, not yet standard or not yet widely implemented language feature, it's best to avoid using that language feature in your code.
That said, as a hack workaround, you can wrap the enum
in a struct
and use a pair of implicit conversions:
struct my_enum {
enum type {
value1,
value2
};
my_enum(type v) : value_(v) { }
operator type() const { return value_; }
private:
type value_;
};