If you want a practical example how to make use of the enum class scope, here is mine:
Code:
enum class Enum1
{
Low_ = 100,
A,
B,
C,
High_
};
enum class Enum2
{
Low_ = 200,
A,
B,
C,
D,
High_
};
template <typename T>
T LoadEnumFromStream(typename std::underlying_type<T>::type x)
{
typedef typename std::underlying_type<T>::type IntType;
if (x <= static_cast<IntType>(T::Low_)
|| x >= static_cast<IntType>(T::High_))
{
throw 0; // Error.
}
return static_cast<T>(x);
}
...
Enum2 en = LoadEnumFromStream<Enum2>(1234);
This safely loads different enums from external storage.