Can some one shed some light on why this code snipit will run though the loop once but then give an assertion failure Expression: vector iterator not decrementable?
for (auto an = a.rbegin(); an != a.rend(); ++an, indexA--) //first number
{
for (auto bn = b.rbegin(); bn != b.rend(); ++bn) //second number
{
if (*an - *bn >= 0)
{
returnVal.push_back(*an - *bn);
a.pop_back();
b.pop_back();
}
else
{
brrow = *an + 10;
a.at(indexA - 1) = a.at(indexA - 1) - 1; // remove 1 from the spot ahead of current digit
returnVal.push_back(brrow - *bn);
a.pop_back();
b.pop_back();
}
}
}