Is it possible to manually define a conversion for an enum class?
问题 Normally you can define a cast for a class by using the following syntax: class Test { public: explicit operator bool() { return false; } }; Is there a way to do this or something similar for an enum class ? 回答1: No, it's not. Actually, an enum class is no class at all. The class keyword is only used because suddenly changing the unscoped enum to a scoped enum would have mean reworking all enums codes. So the committee decided that to distinguish between new-style and old-style enums, the new