Let's suppose that I have struct Foo with move constructor and operator=(Foo&&), and I used it as data member:
Foo f() { Foo foo; //code return foo; } struct Boo { Foo foo; Boo() { foo = f();//1 foo = std::move(f());//2 } }; In case (2) I actually not need std::move, but what if I used it here, does this make something bad, like preventing optimization?
I read this: Why does std::move prevent RVO?
and find out that changing return foo; to return std::move(foo); cause disabling of RVO, but what about (2) does it cause the similar situation? And if so, why?
foo.operator=. It'd be relevant if you hadFoo foo = std::move(f());which is initialization.clang 3.7warn about this, so I wonder, is it bug in warning generation, or I missed somethingstd::moveis using it when transferring data to a subroutine, not from. But I am also waiting for the answer ;)