Closed karolherbst closed 9 years ago
They are, but this is usually in more safier spaces:
safe to assume move:
void func()
{
std::string str(std::string("hiho")); //implicit move, because temporary string object gets destroyed immediatly => rvalue reference,
}
not safe to assume move:
void func(std::string str)
{
std::string str2(str); // no move, because str might be used later on
}
Move only applies on rvalue, not lvalues.
The new rule in c++11 is basically: if you copy a reference, then make the copy in the function header, because there you can move optimize. If you use references instead, move optimizations aren't possible at all.
This should be checked in different places I suppose anyway.
Looks good. I thought move semantics were implicit in some cases?