It is not inheriting the primitive type but rather it tells the implementation to use the specified type(unsigned short
) as the underlying type for the enumerators.
You can just simply treat the enum class object as any other class object and apply the same rules while passing it to functions.
- If you want to modify the enum class object inside function, pass it by reference.
- If you just want to read the object inside function pass it by constant reference.
Move semantics are a language run-time performance enhancing feature which makes use of opportunities to move from rvalues instead of applying copy semantics which are performance intensive. r-value references and move semantics are not only limited to move constructor and move assignment operator but they can also be used with other functions. If you have scenarios which can make use of this optimization it is perfectly fine to make use of them.