考虑到当今关于返回值优化(RVO和NRVO)的编译器的高质量,我想知道在开始添加移动构造函数和移动赋值运算符时实际有意义的类复杂性.
例如,对于这个really_trivial类,我只是假设移动语义不能提供比RVO更多的东西,而NRVO在复制它的实例时已经做了:
class really_trivial
{
int first_;
int second_;
public:
really_trivial();
...
};
Run Code Online (Sandbox Code Playgroud)
在这个semi_complex类中,我会毫不犹豫地添加一个移动构造函数和移动赋值运算符:
class semi_complex
{
std::vector<std::string> strings_;
public:
semi_complex(semi_complex&& other);
semi_complex& operator=(semi_complex&& other);
...
};
Run Code Online (Sandbox Code Playgroud)
那么,在添加移动构造函数和移动赋值运算符时,开始有意义的成员变量的数量和类型是什么?