News for hackers. Stuff that matters.
Re:Implementing Go's defer keyword in C++ by albinofrenchy on Saturday October 21, 2017 @08:29PM (#15524430)
You usually shouldn't use unique_ptr for C api stuff unless you really only need to free it.

Typically though there are custom delete/free API calls you need to make, and to use them with unique_ptr you have to pass that function pointer in as the second argument to the unique_ptr constructor.

At the very least you should have a C++ function that gives you the unique_ptr back that does the right thing; but at that point you almost might as well just make a class and give it member functions to map the C calls.

There are no comments on this comment yet.