私は解決策を何時間も探し、unique_ptr
コピーなし/割り当てなしに関連するコンパイルエラーに対処するためにさまざまな方法を試しました。私は隠しコピーを書き、ベクターがそれを無駄に呼び出さないように割り当てました。
コンパイルエラーの原因となるコードは次のとおりです。
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() {}
};
コンパイルエラーは、プライベートメンバーのアクセスの問題に関連しています。