对于隐式声明的移动赋值运算符,用户声明是什么意思?

What does it means user-declared for Implicitly-declared move assignment operator?

声明

Implicitly-declared move assignment operator

If no user-defined move assignment operators are provided for a class type (struct, class, or union), and all of the following is true:

there are no user-declared copy constructors;
there are no user-declared move constructors;
there are no user-declared copy assignment operators;
there are no user-declared destructors;

with user-declared copy assigment operator does it means only

class_name & class_name :: operator= ( class_name && )

任何 operator=()定义?

示例:

class Bar
{
public:
   Bar() = default;
   SomeClass some;
};

class Foo
{
public:
   Foo() = default;

   Foo& operator=(Bar&& bar) : some(std::move(bar.some))
   {
   }

   SomeClass some;
};

这是否符合隐含声明的移动赋值运算符的条件?

隐式声明的移动构造函数也是如此。

请注意它说 "user-declared copy assignment operators"(强调我的)。并非每个赋值运算符都是复制赋值运算符。

对于class X,一个copy赋值运算符被定义为operator=,它接受一个X类型的参数、X&const X&volatile X&const volatile X&。因此,您的 Foo::operator=(Bar&&) 不是 copy 赋值运算符,因此不会影响移动(或复制)赋值运算符的隐式声明。