我不太清楚在C++11中返回const
值对移动语义的影响。
这两个返回数据成员的函数有什么区别吗?在C++11中const
还是多余的吗?
int GetValueA() { return mValueA; }
const int GetValueB() { return mValueB; }
这些函数怎么办?
int GetValuesAB() { return mValueA + mValueB; }
const int GetValuesCD() { return mValueC + mValueD; }
std::string
,会有所不同?如果是这样,具体是哪些方面的不同? - Walterfoo() += "bar";
。 - Kerrek SBfoo()
返回的对象在+=
操作后被销毁。因此,只有+=
的副作用没有被遗忘... - Walter