Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

`std::make_unique()`, `std::make_shared()`, or another function that wraps `new` and `delete` into an RAII type (commonly called a smart pointer) so that you, the developer, worry less about explicit memory management.

And the standard smart pointers are perfectly extensible enough to wrap things allocated from C libraries (I like to pick on opengl's glalloc() and glfree(), though malloc() and free() are acceptable to pick on too), C-style `FILE` pointers, or even memory-mapped things from `mmap()`

I would also point out that even in 2000, `std::auto_ptr` existed. So even in 2000 you probably should not have been using `new` and `delete`.



std::auto_ptr was broken and didn't work with STL. It wasn't until C++11 introduced "move" semantics that you could really use smart pointers.

You can't really blame him for not using a part of the language that was unusable, right?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: