I'm trying to learn SDL using C++. I've created a window.h
header and a window.cpp
source file for storing a Window class. In window.h
it looks something like this:
Class Window {
public:
Window();
. . .
private:
std::unique_ptr<SDL_Window, void (*)(SDL_Window*)> window;
std::unique_ptr<SDL_Renderer, void (*)(SDL_Renderer*)> renderer;
. . .
}
with some of the code in the class omitted. Then, in my source file, in the definition of the default constructor, I do this:
Window::Window() {
window = std::unique_ptr<SDL_Window, void (*)(SDL_Window*)>(nullptr, SDL_DestroyWindow);
renderer = std::unique_ptr<SDL_Renderer, void (*)(SDL_Renderer*)>(nullptr, SDL_DestroyRenderer);
}
However, when I go to compile, I'm told that unique_ptr [is] constructed with null function pointer deleter
, which as far as I can tell is false. Maybe I'm misunderstanding how to use a unique_ptr
's deleter, but I cannot figure out what's wrong. Is there something I'm missing or have I completely misunderstood what I'm doing?