Thread 105922599 - /g/ [Archived: 228 hours ago]

Anonymous
7/16/2025, 6:51:39 AM No.105922599
hqdefault
hqdefault
md5: f87c2699a0ffedcdf16ae07f036b2c97🔍
How do I properly wrap everything in my Cpp app using smart pointers?

I still can't understand how to wrap SDL C destruction functions.
Anonymous
7/16/2025, 7:10:44 AM No.105922700
https://eb2.co/blog/2014/04/c-14-and-sdl2-managing-resources/
Anonymous
7/16/2025, 12:27:59 PM No.105924482
>I still can't understand how to wrap SDL C destruction functions.
Here is the documentation and example code for using the smart pointer classes unique_ptr and shared_ptr in C++:
https://en.cppreference.com/w/cpp/memory/unique_ptr/unique_ptr.html
https://en.cppreference.com/w/cpp/memory/shared_ptr/shared_ptr.html

Specifically, this is the documentation for the constructors for these classes. You are going to want to reference the examples that use a custom deleter function. You should be able to just pass the function name for the SDL destructor in the same parameter you might use a lambda in.