#include <iostream>
#include <vector>
struct foo {
int value;
explicit foo(int value) : value(value) {
std::cout << "foo(" << value << ")\n";
}
foo(foo const& other) : value(other.value) {
std::cout << "foo(foo(" << value << "))\n";
}
foo(foo&& other) : value(std::move(other.value)) {
other.value = -1;
std::cout << "foo(move(foo(" << value << "))\n";
}
~foo() {
if (value != -1)
std::cout << "~foo(" << value << ")\n";
}
};
int main() {
std::vector<foo> foos;
foos.emplace_back(1);
foos.emplace_back(2);
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgoKc3RydWN0IGZvbyB7CiAgICBpbnQgdmFsdWU7CgogICAgZXhwbGljaXQgZm9vKGludCB2YWx1ZSkgOiB2YWx1ZSh2YWx1ZSkgewogICAgICAgIHN0ZDo6Y291dCA8PCAiZm9vKCIgPDwgdmFsdWUgPDwgIilcbiI7CiAgICB9CgogICAgZm9vKGZvbyBjb25zdCYgb3RoZXIpIDogdmFsdWUob3RoZXIudmFsdWUpIHsKICAgICAgICBzdGQ6OmNvdXQgPDwgImZvbyhmb28oIiA8PCB2YWx1ZSA8PCAiKSlcbiI7CiAgICB9CgogICAgZm9vKGZvbyYmIG90aGVyKSA6IHZhbHVlKHN0ZDo6bW92ZShvdGhlci52YWx1ZSkpIHsKICAgICAgICBvdGhlci52YWx1ZSA9IC0xOwogICAgICAgIHN0ZDo6Y291dCA8PCAiZm9vKG1vdmUoZm9vKCIgPDwgdmFsdWUgPDwgIikpXG4iOwogICAgfQoKICAgIH5mb28oKSB7CiAgICAgICAgaWYgKHZhbHVlICE9IC0xKQogICAgICAgICAgICBzdGQ6OmNvdXQgPDwgIn5mb28oIiA8PCB2YWx1ZSA8PCAiKVxuIjsKICAgIH0KfTsKCmludCBtYWluKCkgewogICAgc3RkOjp2ZWN0b3I8Zm9vPiBmb29zOwogICAgZm9vcy5lbXBsYWNlX2JhY2soMSk7CiAgICBmb29zLmVtcGxhY2VfYmFjaygyKTsKfQ==