我正在学习智能指针,编译时遇到以下错误。
这是我的课程和实验我添加了一个std :: unique_ptr类型的矢量。但是,这样做后我收到错误消息
class TreeNode {
public:
using node_ptr=std::unique_ptr<TreeNode>;
float totValue = 0;
float nVisits = 0;
uint8_t move;
HexBoard* board;
std::vector<TreeNode> children;
//added this
std::vector<node_ptr>test;
void calculateIteration(Union unionF);
uint8_t select();
uint8_t selectBestMove();
bool isLeaf();
void expand();
void update(float value);
};
In file included from C:/PROGRA~2/MINGW-~1/X86_64~2.0-P/mingw64/lib/gcc/x86_64-w64-mingw32/7.1.0/include/c++/memory:64:0,
from C:\Users\Robin\source\repos\HexVC++\HexVC++\TreeNode.h:6,
from C:\Users\Robin\source\repos\HexVC++\HexVC++\HexVC.cpp:4:
C:/PROGRA~2/MINGW-~1/X86_64~2.0-P/mingw64/lib/gcc/x86_64-w64-mingw32/7.1.0/include/c++/bits/stl_construct.h: In instantiation of 'void std::_Construct(_T1*, _Args&& ...) [with _T1 = std::unique_ptr<TreeNode>; _Args = {const std::unique_ptr<TreeNode, std::default_delete<TreeNode> >&}]':
C:/PROGRA~2/MINGW-~1/X86_64~2.0-P/mingw64/lib/gcc/x86_64-w64-mingw32/7.1.0/include/c++/bits/stl_uninitialized.h:83:18: required from 'static _ForwardIterator std::__uninitialized_copy<_TrivialValueTypes>::__uninit_copy(_InputIterator, _InputIterator, _ForwardIterator) [with _InputIterator = __gnu_cxx::__normal_iterator<const std::unique_ptr<TreeNode>*, std::vector<std::unique_ptr<TreeNode> > >; _ForwardIterator = std::unique_ptr<TreeNode>*; bool _TrivialValueTypes = false]'
C:/PROGRA~2/MINGW-~1/X86_64~2.0-P/mingw64/lib/gcc/x86_64-w64-mingw32/7.1.0/include/c++/bits/stl_uninitialized.h:134:15: required from '_ForwardIterator std::uninitialized_copy(_InputIterator, _InputIterator, _ForwardIterator) [with _InputIterator = __gnu_cxx::__normal_iterator<const std::unique_ptr<TreeNode>*, std::vector<std::unique_ptr<TreeNode> > >; _ForwardIterator = std::unique_ptr<TreeNode>*]'
C:/PROGRA~2/MINGW-~1/X86_64~2.0-P/mingw64/lib/gcc/x86_64-w64-mingw32/7.1.0/include/c++/bits/stl_uninitialized.h:289:37: required from '_ForwardIterator std::__uninitialized_copy_a(_InputIterator, _InputIterator, _ForwardIterator, std::allocator<_Tp>&) [with _InputIterator = __gnu_cxx::__normal_iterator<const std::unique_ptr<TreeNode>*, std::vector<std::unique_ptr<TreeNode> > >; _ForwardIterator = std::unique_ptr<TreeNode>*; _Tp = std::unique_ptr<TreeNode>]'
C:/PROGRA~2/MINGW-~1/X86_64~2.0-P/mingw64/lib/gcc/x86_64-w64-mingw32/7.1.0/include/c++/bits/stl_vector.h:331:31: required from 'std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&) [with _Tp = std::unique_ptr<TreeNode>; _Alloc = std::allocator<std::unique_ptr<TreeNode> >]'
C:\Users\Robin\source\repos\HexVC++\HexVC++\TreeNode.h:21:7: required from here
C:/PROGRA~2/MINGW-~1/X86_64~2.0-P/mingw64/lib/gcc/x86_64-w64-mingw32/7.1.0/include/c++/bits/stl_construct.h:75:7: error: use of deleted function 'std::unique_ptr<_Tp, _Dp>::unique_ptr(const std::unique_ptr<_Tp, _Dp>&) [with _Tp = TreeNode; _Dp = std::default_delete<TreeNode>]'
{ ::new(static_cast<void*>(__p)) _T1(std::forward<_Args>(__args)...); }
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from C:/PROGRA~2/MINGW-~1/X86_64~2.0-P/mingw64/lib/gcc/x86_64-w64-mingw32/7.1.0/include/c++/memory:80:0,
from C:\Users\Robin\source\repos\HexVC++\HexVC++\TreeNode.h:6,
from C:\Users\Robin\source\repos\HexVC++\HexVC++\HexVC.cpp:4:
C:/PROGRA~2/MINGW-~1/X86_64~2.0-P/mingw64/lib/gcc/x86_64-w64-mingw32/7.1.0/include/c++/bits/unique_ptr.h:388:7: note: declared here
unique_ptr(const unique_ptr&) = delete;
^~~~~~~~~~
mingw32-make.exe[3]: *** [CMakeFiles\HexVC++.dir\build.make:62: CMakeFiles/HexVC++.dir/HexVC.cpp.obj] Error 1
mingw32-make.exe[3]: *** Waiting for unfinished jobs....
mingw32-make.exe[2]: *** [CMakeFiles\Makefile2:67: CMakeFiles/HexVC++.dir/all] Error 2
mingw32-make.exe[1]: *** [CMakeFiles\Makefile2:79: CMakeFiles/HexVC++.dir/rule] Error 2
mingw32-make.exe: *** [Makefile:117: HexVC++] Error 2
这个错误是什么意思?