Tag: destructor
-
std::move and lifetime of temporary objects
11 Can someone explain the execution order of this code? struct Foo { ~Foo() { std::cout << "1"; } }; int main() { const Foo& bar = Foo(); const Foo& baz = std::move(Foo()); std::cout << "2"; } The following code prints 121. I understand why I get 1 after 2, it’s because the lifetime of…