aprotyas / aprotyas.github.io

Personal website
https://aprotyas.github.io
MIT License
3 stars 0 forks source link

Blog post about marrying the SDL API with modern C++ #32

Open aprotyas opened 1 year ago

aprotyas commented 1 year ago

Something that's worked reasonably well for me so far...

struct SdlDeleter
{
  void operator()(SDL_Window* window)
  {
    if (window != nullptr)
    {
      SDL_DestroyWindow(window);
    }
  }
};

using WindowPtr = std::unique_ptr<SDL_Window, SdlDeleter>;

You might also want to talk about the incomplete struct pattern and why that prevents you from doing a simple std::unique_ptr<WindowPtr> approach.