std::tr1::shared_ptr<SDL_Surface> surface; surface.reset(SDL_LoadImage(imageFileName.c_str()), std::tr1::bind(SDL_FreeSurface, std::tr1::placeholders::_1)); // Now you can do whatever and RAII will take care of the memory management.
Remember: You must set the deleter to be SDL_FreeSurface, because otherwise (and in std::auto_ptr) the c++ delete will just be called, which will cause undefined behaviour with things not created via new.
I generally do this with OpenGL textures but there is no reason this wont work for SDL textures.
If you are not using the very latest compiler you will need to include the technical report 1 versions of memory and functional.
#include <tr1/functional>
#include <tr1/memory>