Couple of questions about SDL_Window and unique_ptr

前端 未结 2 1162
灰色年华
灰色年华 2021-01-13 00:20

I currently had a problem with storing a SDL_Window pointer as a std::unique_ptr.
What I tried was:

std::unique_ptr window_;

2条回答
  •  无人共我
    2021-01-13 00:57

    I find this cleaner:

        auto window = std::unique_ptr>(
                SDL_CreateWindow("Test", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, kWindowWidth, kWindowHeight, 0),
                SDL_DestroyWindow
        );
    

提交回复
热议问题