#include <iostream>
struct data
{
~data() { std::cout << "data: destructor\n"; }
};
struct sample
{
//data value;
int value;
~sample() { std::cout << "sample: destructor\n"; }
};
int main()
{
std::cout << "begin...\n";
{
const auto& ref = sample().value;
std::cout << "work with temporary...\n";
}
std::cout << "finished!\n";
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKCnN0cnVjdCBkYXRhCnsKICAgIH5kYXRhKCkJeyBzdGQ6OmNvdXQgPDwgImRhdGE6IGRlc3RydWN0b3JcbiI7IH0KfTsKCgpzdHJ1Y3Qgc2FtcGxlCnsKCS8vZGF0YSB2YWx1ZTsKCWludCB2YWx1ZTsKCQogICAgfnNhbXBsZSgpCXsgc3RkOjpjb3V0IDw8ICJzYW1wbGU6IGRlc3RydWN0b3JcbiI7IH0KfTsKCgppbnQgbWFpbigpIAp7CiAgICBzdGQ6OmNvdXQgPDwgImJlZ2luLi4uXG4iOwogICAgewogICAgCWNvbnN0IGF1dG8mIHJlZiA9IHNhbXBsZSgpLnZhbHVlOwogICAgCXN0ZDo6Y291dCA8PCAid29yayB3aXRoIHRlbXBvcmFyeS4uLlxuIjsKICAgIH0KICAgIHN0ZDo6Y291dCA8PCAiZmluaXNoZWQhXG4iOwoKfQ==