Fix improper Chromosome copy assingment operator

This commit is contained in:
Joscha 2017-05-20 23:57:44 +00:00
parent 901a5f2b3c
commit c10a12f29c

View file

@ -59,6 +59,8 @@ Chromosome& Chromosome::operator=(const Chromosome& other)
{ {
// reserve to other's size/capacity? // reserve to other's size/capacity?
this->genes.clear();
if (this != &other) { if (this != &other) {
for (auto& ptr : other.genes) { for (auto& ptr : other.genes) {
this->genes.push_back(std::unique_ptr<Gene>(Gene::copy(ptr.get()))); this->genes.push_back(std::unique_ptr<Gene>(Gene::copy(ptr.get())));