So I have this code:
foo<T>& foo<T>::operator=(foo&& M)
{
if (this != &M)
{
// Do something
}
}
and I am quite confused as to what this != &M
means here. What happens when you try to get the memory address of a rvalue reference? Is that what this code is trying to do?
this != &F
do exactly? What does it check?Sorry if this is dumb. I am quite new to C++ and I am trying to learns how rvalue references work and why they are used in cases like this.
Thanks!
It's simply checking for self-assignment. If the address of the object being passed in is the same as this
then do nothing.