dimanche 2 décembre 2018

Is a self-assignment check really required while implementing move assignment operator for a class?

Type &Type::operator=(Type &&rhs)
{
if(this == &rhs) //is there any need of self-assignment . 
returh *this ;
}
...
}

//since it will be called on r-value so why self-assignment ??

Aucun commentaire:

Enregistrer un commentaire