I currently had a problem with storing a SDL_Window pointer as a std::unique_ptr.
What I tried was:
std::unique_ptr<SDL_Window> window_;
The solution:
std::unique_ptr<SDL_Window, void(*)(SDL_Window*)> window_;
The first attempt kept throwing errors in the memory header, saying SDL_Window is an incomplete type. Well I know that SDL_Window is a struct and can't be instanciated with
SDL_Window* window_ = new SDL_Window();
therefore the instanciation is done with SDL_CreateWindow(params).
Questions are:
Why can't I call the default constructor (or any other) for SDL_Window?
Why does the unique_ptr needs a deleter in this case, but not here:
renderSystem_ = std::unique_ptr<Renderer::RenderSystem>(new Renderer::RenderSystem());
RenderSystem being a class with just a default constructor, destructor.
Is it because the unique_ptr can access the destructor, which acts as the deleter and doesn't need to come as a template argument?