M:\Include/MyEntity.hpp:13:7: required from here
C:/tools/mingw64/x86_64-w64-mingw32/include/c++/bits/stl_algobase.h:340:18: error: use of delete
*__result = *__first;
^
In file included from C:/tools/mingw64/x86_64-w64-mingw32/include/c++/memory:81:0,
from M:\Include/MyGame.hpp:3,
from M:\Src\mainer.cpp:1:
C:/tools/mingw64/x86_64-w64-mingw32/include/c++/bits/unique_ptr.h:357:19: note: declared here
unique_ptr& operator=(const unique_ptr&) = delete;
^
In file included from C:/tools/mingw64/x86_64-w64-mingw32/include/c++/memory:62:0,
from M:\Include/MyGame.hpp:3,
from M:\Src\mainer.cpp:1:
C:/tools/mingw64/x86_64-w64-mingw32/include/c++/bits/stl_algobase.h: In instantiation of 'static
C:/tools/mingw64/x86_64-w64-mingw32/include/c++/bits/stl_algobase.h:400:44: required from '_OI
C:/tools/mingw64/x86_64-w64-mingw32/include/c++/bits/stl_algobase.h:436:45: required from '_OI
C:/tools/mingw64/x86_64-w64-mingw32/include/c++/bits/stl_algobase.h:469:8: required from '_OI
C:/tools/mingw64/x86_64-w64-mingw32/include/c++/bits/vector.tcc:211:17: required from 'std::ve
M:\Include/MyEntity.hpp:13:7: required from here
C:/tools/mingw64/x86_64-w64-mingw32/include/c++/bits/stl_algobase.h:340:18: error: use of delete
*__result = *__first;
^
thanks for the reply
yeah, that is whats confusing me, because the only place i add something
to the vector is on line 63, and i made sure to use std::move there :\
do you think using shared_pointers would work too?
it doesn't seem to give me any errors when i define the vector as
template<typename T>
T& AddComponent()
{
static_assert(!Has<T>(), "TRYING TO ADD MULTIPLE OF SAME TYPE COMPONENTS");
T* comp = new T();
comp->Entity = this;
You haven't provided enough code for us to do anything other than guess. If you want solid answers you're going to need to post more information. The code you provided is not the "whole code" it is only a snippet of the code.
The error says that your file mainer.cpp has #include "MyGame.hpp" at line 1.
And MyGame.hpp has #include <memory> at line 3
And memory has #include <stl_algobase.h> at line 81
And algobase.h has code that assigns one unique_ptr to another. at line 340.
I wonder if it's even possible to have a vector<unique_ptr<> > Vector<> has a copy constructor and assignment operator. How would those work when the template type can't be copied?
M:\Include/MyEntity.hpp:13:7: required from here
C:/tools/mingw64/x86_64-w64-mingw32/include/c++/bits/stl_algobase.h:340:18: error: use of delete
*__result = *__first;
^
In file included from C:/tools/mingw64/x86_64-w64-mingw32/include/c++/memory:81:0,
from M:\Include/MyGame.hpp:3,
from M:\Src\mainer.cpp:1:
I wonder if it's even possible to have a vector<unique_ptr<> > Vector<> has a copy constructor and assignment operator. How would those work when the template type can't be copied?
It is possible. std::vector only requires the elements to be movable. If the elements are not copyable it means you will not be able to copy the vector but you can still move it.