在 Effective Modern C++ 中,第 17 项(了解特殊成员函数 generation),Scott Meyers 说生成的特殊移动成员函数(移动构造函数和移动赋值运算符)对类的非静态数据成员执行“成员移动”。 p>
The move operations are generated only if they’re needed, and if they are generated, they perform “memberwise moves” on the non-static data members of the class.
我试图理解非静态条件,但我不能,谁能向我解释为什么他们不能对静态数据成员执行该操作?
最佳答案
因为静态成员不是该类创建的对象的一部分。虽然它们不需要移动(或在复制构造函数的情况下复制)。
关于c++ - 编译器生成的静态数据成员移动成员函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49046476/