mercredi 26 août 2015

What is the purpose of a move assignment operator or move constructor with a const argument? [duplicate]

This question already has an answer here:

According to cppreference here and here,

Under Implicitly-declared move constructor

A class can have multiple move assignment operators, e.g. both T& T::operator=(const T&&) and T& T::operator=(T&&). If some user-defined move assignment operators are present, the user may still force the generation of the implicitly declared move assignment operator with the keyword default.

and under Implicitly-declared move assignment operator

A class can have multiple move assignment operators, e.g. both T& T::operator=(const T&&) and T& T::operator=(T&&). If some user-defined move assignment operators are present, the user may still force the generation of the implicitly declared move assignment operator with the keyword default.

What is the purpose of a move symantic with argument const T&&? Surely a move'ing function needs to modify the argument? (Considering if the class in question manages a dynamically assigned block of memory on the heap, pointed to by a pointer?)

Aucun commentaire:

Enregistrer un commentaire