У меня ошибка с этим кодом:
void Game::changeState(gameState type) // gameState is an enum
{
if (!states.empty()) // deleting the last state
{
states.back()->clean();
states.pop_back();
}
switch(type)
{
case editorState:
{
states.push_back(std::move(std::unique_ptr<EditorState> (new EditorState)));
states.back()->init();
break;
}
case menuState:
{
states.push_back(std::move(std::unique_ptr<MenuState> (new MenuState)));
states.back()->init();
break;
}
}
}
Вектор:
std::vector<std::unique_ptr<GameState>> states;
Сообщение об ошибке:
c: \ program files (x86) \ codeblocks \ mingw \ bin .. \ lib \ gcc \ mingw32 \ 4.7.1 \ include \ c ++ \ bits \ unique_ptr.h || В экземпляре 'void std :: default_delete ‹_Tp> :: operator () (_ Tp *) const [with _Tp = GameState] ': | c: \ program files (x86) \ codeblocks \ mingw \ bin .. \ lib \ gcc \ mingw32 \ 4.7 .1 \ include \ c ++ \ bits \ unique_ptr.h | 245 | требуется из 'void std :: unique_ptr ‹_Tp, _Dp> :: reset (std :: unique_ptr‹ _Tp, _Dp> :: pointer) [с _Tp = GameState; _Dp = std :: default_delete; std :: unique_ptr ‹_Tp, _Dp> :: pointer = GameState *] '| c: \ program files (x86) \ codeblocks \ mingw \ bin .. \ lib \ gcc \ mingw32 \ 4.7.1 \ include \ c ++ \ bits \ unique_ptr.h | 169 | требуется из 'std :: unique_ptr ‹_Tp, _Dp> :: ~ unique_ptr () [с _Tp = GameState; _Dp = std :: default_delete] '| c: \ program files (x86) \ codeblocks \ mingw \ bin .. \ lib \ gcc \ mingw32 \ 4.7.1 \ include \ c ++ \ bits \ stl_construct.h | 95 | требуется из 'void std :: _ Destroy (_Tp *) [with _Tp = std :: unique_ptr]' | c: \ program files (x86) \ codeblocks \ mingw \ bin .. \ lib \ gcc \ mingw32 \ 4.7.1 \ include \ c ++ \ bits \ stl_construct.h | 105 | требуется из 'static void std :: _ Destroy_aux ‹> :: __ destroy (_ForwardIterator, _ForwardIterator) [с _ForwardIterator = std :: unique_ptr *; bool = false] '| c: \ program files (x86) \ codeblocks \ mingw \ bin .. \ lib \ gcc \ mingw32 \ 4.7.1 \ include \ c ++ \ bits \ stl_construct.h | 128 | < strong> требуется из 'void std :: _ Destroy (_ForwardIterator, _ForwardIterator) [с _ForwardIterator = std :: unique_ptr *]' | c: \ program files (x86) \ codeblocks \ mingw \ bin .. \ lib \ gcc \ mingw32 \ 4.7.1 \ include \ c ++ \ bits \ stl_construct.h | 155 | требуется из 'void std :: _ Destroy (_ForwardIterator, _ForwardIterator, std :: allocator ‹_T2> &) [с _ForwardIterator = std :: unique_ptr *; _Tp = std :: unique_ptr] '| c: \ program files (x86) \ codeblocks \ mingw \ bin .. \ lib \ gcc \ mingw32 \ 4.7.1 \ include \ c ++ \ bits \ stl_vector.h | 403 | требуется из 'std :: vector ‹_Tp, _Alloc> :: ~ vector () [с _Tp = std :: unique_ptr; _Alloc = std :: allocator>] '| ... \ game.h | 15 | требуется отсюда | c: \ program files (x86) \ codeblocks \ mingw \ bin. . \ lib \ gcc \ mingw32 \ 4.7.1 \ include \ c ++ \ bits \ unique_ptr.h | 63 | ошибка: недопустимое применение sizeof к неполному типу GameState | || == = Сборка завершена: 1 ошибка, 12 предупреждений (0 минут, 1 секунда) === |
Мой код выше работает, когда я использую указатели по умолчанию, но когда я использую unique_ptr, он дает мне указанную выше ошибку ...
РЕДАКТИРОВАТЬ: Вот game.h: https://pastebin.com/DiBbXrC6 И состояние игры: https://pastebin.com/JD3VrktJ