我需要一些帮助来理解移动赋值运算符的继承过程。对于给定的基类
class Base
{
public:
/* Constructors and other utilities */
/* ... */
/* Default move assignment operator: */
Base &operator=(Base &&) = default;
/* One can use this definition, as well: */
Base &operator=(Base &&rhs) {std::move(rhs); return *this;}
/* Data members in Base */
/* ... */
};
class Derived : public Base
{
public:
/* Constructors that include inheritance and other utilities */
/* ... */
Derived &operator=(Derived &&rhs);
/* Additional data members in Derived */
/* ... */
};
我不太确定如何在派生类中调用基本移动赋值运算符?我应该只使用范围运算符并说
Base::std:move(rhs);
其次是类std::move(...)
中定义的附加项目的后续Derived
,还是有其他方法?