Is doing something like this safe? I'm unsure if the execution order is guaranteed or not.
auto foo = std::make_unique<Foo>();
foo->Bar(std::move(foo));
It will work fine.
The sequence:
std::move(foo)
then evaluate foo->
(or the other way around, which does not matter as neither changes the state of the foo
pointer).Foo::Bar(...)
on the target object obtained in #1 passing the rvalue-casted foo
also obtained in #1.Probably not the cleanest code style.