Re:The Myth of Smart Pointers
by TillE on Thursday November 30, 2023 @05:30PM
(#38480115)
Yeah this just comes across as not understanding pointer ownership, or memory allocation in general. It's not a trivial issue, especially if you're dealing with weird C libraries. Sometimes you don't own a pointer you allocated. Sometimes you need a custom deleter.
Within your own code you can just use std::make_unique and rely on the compiler to catch errors, but when passing raw pointers to libraries you really gotta read the docs and work carefully.
Within your own code you can just use std::make_unique and rely on the compiler to catch errors, but when passing raw pointers to libraries you really gotta read the docs and work carefully.