我已经搜索了几个小时来寻找解决方案,并尝试了不同的方法来解决unique_ptr
与无复制/无分配相关的编译错误。我什至写了一个隐藏的副本并分配以防止vector调用它无济于事。
以下是导致编译错误的代码:
class World{
World(const World&) {}
World& operator=(const World&) {return *this; }
std::vector<std::vector<std::unique_ptr<Organism>>> cell_grid;
public:
World() {
cell_grid = std::vector<std::vector<std::unique_ptr<Organism>>> (20, std::vector<std::unique_ptr<Organism>> (20, nullptr));
}
~World() {}
};
编译错误与私有成员访问问题有关。