On Fri, Jun 28, 2019 at 1:08 PM degski
On Fri, 28 Jun 2019 at 11:38, Andrey Semashev via Boost
wrote: Most C-style APIs follow the new/delete pattern, where you have a function that allocates and initializes a structure, returning a pointer to it, and another one to free it, along with any associated resources.
Doesn't sound like overkill to me, now I have no dependency and I can add details at will [without reading any docs].
Using a smart pointer to store a pointer to that structure is perfectly valid, and the easiest and most natural thing to do.
Right, most natural since C++11 that is then.
And using a smart pointer to manage that resource is perfectly adequate.
It's the "if-I-have-a-hammer-everything-looks-like-a-nail-syndrom".
Maybe, but I'm definitely not looking forward wrapping something like AVCodecContext in a custom RAII wrapper, when I can just use unique_ptr with a deleter.