Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- window = unique_ptr<SDL_Window, decltype(free) *>
- reinterpret_cast<SDL_Window *>(malloc(sizeof(SDL_Window))),
- free};
- &window.get()
- // or
- &&(*window)
- // or
- &window
- // and even
- &(&(*(window.get())))
- SDL_Window *window_ptr;
- unique_ptr<SDL_Window> window;
- window = unique_ptr<SDL_Window, decltype(SDL_DestroyWindow)> (
- window_ptr,
- SDL_DestroyWindow);
- SDL_CreateWindowAndRenderer(500, 500, SDL_WINDOW_SHOWN, &window_ptr, &renderer_ptr);
- /usr/include/c++/5/bits/unique_ptr.h:272:18: error: no match for ‘operator=’
- (operand types are ‘std::unique_ptr<SDL_Window>::deleter_type
- {aka std::default_delete<SDL_Window>}’ and ‘void (*)(void*)’)
- get_deleter() = std::forward<_Ep>(__u.get_deleter());
- SDL_Window *window_;
- SDL_Renderer *renderer_;
- SDL_CreateWindowAndRenderer (/* ... */, &window_, &renderer_);
- unique_ptr<SDL_Window, decltype(&SDL_DestroyWindow)>
- window(window_, &SDL_DestroyWindow);
- std::unique_ptr<myclass> uptr;
- myclass*& inside = *reinterpret_cast<myclass**>(&uptr);
- #include <iostream>
- #include <memory>
- class myclass {
- public:
- myclass() {
- }
- ~myclass() {
- std::cout << "It works!n";
- }
- };
- int main()
- {
- std::unique_ptr<myclass> uptr;
- myclass*& inside = *reinterpret_cast<myclass**>(&uptr);
- inside = new myclass();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement