From 6eddb4552ac00c0faa49a48413e83d8076989827 Mon Sep 17 00:00:00 2001 From: Trifon Triantafillidis Date: Thu, 5 Apr 2018 22:52:50 +0300 Subject: [PATCH] Avoid index out of bounds error with MSVC Variable i is first evaluated on the right part of the assignment and was causing an "index out of bounds error". --- src/Chromosome.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Chromosome.hpp b/src/Chromosome.hpp index 0ab94ba..8e66335 100644 --- a/src/Chromosome.hpp +++ b/src/Chromosome.hpp @@ -146,7 +146,8 @@ inline void Chromosome::evaluate() int i(0); for (const auto& x : ptr->param) { // decoding chromosome: converting chromosome string into a real value - param[i] = x->decode(chr.substr(ptr->idx[i++], x->size())); + param[i] = x->decode(chr.substr(ptr->idx[i], x->size())); + i++; } // computing objective result(s) result = ptr->Objective(param);