#include <iostream>
#include <memory>
class myCla {
public:
~myCla() { std::cout << "hello RAII" << std::endl; };
};
std::unique_ptr<myCla[]> ownerPointerCreator(size_t nElem) {
return std::unique_ptr<myCla[]>(new myCla[nElem]);
};
int main() {
/*std::unique_ptr<myCla[]>*/ auto uniquee = ownerPointerCreator(10);
//creates unique_ptr to 10 elements which are automatically deleted
std::cout << "ohoho" << std::endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8bWVtb3J5PgoKY2xhc3MgbXlDbGEgewoJcHVibGljOgoJfm15Q2xhKCkgeyBzdGQ6OmNvdXQgPDwgImhlbGxvIFJBSUkiIDw8IHN0ZDo6ZW5kbDsgfTsKfTsKCnN0ZDo6dW5pcXVlX3B0cjxteUNsYVtdPiBvd25lclBvaW50ZXJDcmVhdG9yKHNpemVfdCBuRWxlbSkgewoJcmV0dXJuIHN0ZDo6dW5pcXVlX3B0cjxteUNsYVtdPihuZXcgbXlDbGFbbkVsZW1dKTsKfTsKCmludCBtYWluKCkgewovKnN0ZDo6dW5pcXVlX3B0cjxteUNsYVtdPiovIGF1dG8gdW5pcXVlZSA9IG93bmVyUG9pbnRlckNyZWF0b3IoMTApOwovL2NyZWF0ZXMgdW5pcXVlX3B0ciB0byAxMCBlbGVtZW50cyB3aGljaCBhcmUgYXV0b21hdGljYWxseSBkZWxldGVkCnN0ZDo6Y291dCA8PCAib2hvaG8iIDw8IHN0ZDo6ZW5kbDsKcmV0dXJuIDA7Cn0=