Move from *this in an rvalue method?
Posted
by FredOverflow
on Stack Overflow
See other posts from Stack Overflow
or by FredOverflow
Published on 2010-06-12T12:19:57Z
Indexed on
2010/06/12
13:02 UTC
Read the original article
Hit count: 328
In C++0x, methods can be overloaded on whether or not the expression that denotes the object on which the method is called is an lvalue or an rvalue. If I return *this
from a method called via an rvalue, do I need to explicitly move
from *this
or not?
Foo Foo::method() &&
{
return std::move(*this); // Is this move required or not?
}
Unfortunately, I can't simply test this on my compiler since g++ does not support this feature yet :(
© Stack Overflow or respective owner