我基本上有两个问题可能是相关的,所以我将它们合二为一。
在传递给函数时,我们应该通过引用还是值来传递 C++11 中的枚举类。它是一种继承原始类型,但它是传递的整个对象吗?因为枚举类是类型安全的;
enum class MyEnumClass : unsigned short {
Flag1 = 0,
Flag2 = 1,
Flag3 = 2,
Flag4 = 4,
};
现在假设我们有函数 sig
const char* findVal(const MyEnumClass& enumClass);
^
should this be by const ref? __|
我的另一个问题在这里-
SHOULD IT BE BY MOVE like (MyEnumClass&&) - I am still learning/understanding
move semantics and rvalue so I am not sure if move semantics are only for
constructors or can be for member or static funcs -