I did not find any formulations in the C ++ 11 standard, which says that unscoped enums are deprecated, but from a pragmatic point of view, I wonder if they are still useful. Many people in my team are used to converting irregular transfers in the transfer area, but this caused some headache:
class foo
{
public:
enum MyEnum { One, Two, Three };
};
They convert this value to:
class foo
{
public:
enum class MyEnum { One, Two, Three };
};
This means that when using these counters instead, foo::Oneit looks like foo::MyEnum::One. I requested the following best practices:
- If you convert to an enum scope, move it from the classes to the global scope or namespace (to improve usability and avoid the last use case above).
- enum unscoped, , namespace/class/function/etc, .
, # 1 , .
, , . ?