I\'m trying to work out how to use std::shared_ptr with a custom deleter. Specifically, I\'m using it with SDL_Surface as:
std::shared_ptr
std::shared_ptr(SDL_LoadBMP(....), [=](SDL_Surface* surface)
{
std::cout << "Deleting surface\n";
SDL_FreeSurface(surface);
});
or
void DeleteSurface(SDL_Surface* surface)
{
std::cout << "Deleting surface\n";
SDL_FreeSurface(surface);
}
std::shared_ptr(SDL_LoadBMP(....), DeleteSurface);
EDIT:
Seeing your updated question, DeleteSurface
should be a non-member function, otherwise you need to use std::bind
or std::mem_fn
or some other member function pointer adapter.