#include <iostream>
#include <list>
class Whine {
public:
Whine() {
std::cout << this << ": Whine constructed." << std::endl;
}
~Whine() {
std::cout << this << ": Whine destroyed." << std::endl;
}
};
int main()
{
std::list<Whine *> wl;
wl.push_back(new Whine);
wl.push_back(new Whine);
wl.push_back(new Whine);
for (std::list<Whine *>::const_iterator it = wl.begin(); it != wl.end(); ++it)
delete *it;
wl.clear();
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8bGlzdD4KCmNsYXNzIFdoaW5lIHsKcHVibGljOgogICAgV2hpbmUoKSB7CiAgICAgICAgc3RkOjpjb3V0IDw8IHRoaXMgPDwgIjogV2hpbmUgY29uc3RydWN0ZWQuIiA8PCBzdGQ6OmVuZGw7CiAgICB9CgogICAgfldoaW5lKCkgewogICAgICAgIHN0ZDo6Y291dCA8PCB0aGlzIDw8ICI6IFdoaW5lIGRlc3Ryb3llZC4iIDw8IHN0ZDo6ZW5kbDsKICAgIH0KfTsKCmludCBtYWluKCkKewogICAgc3RkOjpsaXN0PFdoaW5lICo+IHdsOwoKICAgIHdsLnB1c2hfYmFjayhuZXcgV2hpbmUpOwogICAgd2wucHVzaF9iYWNrKG5ldyBXaGluZSk7CiAgICB3bC5wdXNoX2JhY2sobmV3IFdoaW5lKTsKCiAgICBmb3IgKHN0ZDo6bGlzdDxXaGluZSAqPjo6Y29uc3RfaXRlcmF0b3IgaXQgPSB3bC5iZWdpbigpOyBpdCAhPSB3bC5lbmQoKTsgKytpdCkKICAgICAgICBkZWxldGUgKml0OwoKICAgIHdsLmNsZWFyKCk7Cn0=