jeudi 3 mai 2018

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

The statement

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 && )

or any operator=() defined?

Example:

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

class Foo
{
public:
   Foo() = default;

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

   SomeClass some;
};

Does that match the condition for an implitely-declared move assigmnent operator?

The same goes for the implicitly-declared move constructor.

Aucun commentaire:

Enregistrer un commentaire