The following code is causing this error:
if (bestLine.size() > searchDepth - depth)
bestLine.erase(bestLine.begin(), bestLine.end() - searchDepth - depth);
When I checked the value of searchDepth - depth at the time of the error, it was 0.
So essentially,
if (bestLine.size() > 0)
bestLine.erase(bestLine.begin(), bestLine.end());
is causing this error. (Or not. See comments below.)
To my knowledge the above code should erase the entire vector, which is the desired behavior in this case.
What am I doing wrong?
Try adding parentheses to your expression: bestLine.end() - (searchDepth - depth). The result is very different if simply evaluated left-to-right.
You check if bestLine.size() is greater then searchDepth - depth, but then you substract searchDepth + depth. Change the sign before depth in the subtraction:
bestLine.erase(bestLine.begin(), bestLine.end() - searchDepth *+* depth);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With