I'm having trouble understanding the behavior of unique pointers. If I allocate an object on the heap...
std::unique_ptr<GameState> mMenuPtr(new MainMenu);
gameStates.push(std::move(mMenuPtr)); //pointer loses ownership of MainMenu during move
GameState* statePtr = sScreen.get();
unique_ptr will always free the object, unless
release is called.
GameState object is still allocated on the heap. Ownership of the pointer was passed to the stack/vector. The
unique_ptr on the stack will do nothing in its destructor (since its pointer is NULL after the move), and the destructor of the stack/vector will call delete if the stack/vector is destructed before the object is moved again.