Thank you very much. It's helpful.
But if you could help me with maxsize, it would be great. Or check if out and/or input is less than 20 digits. Thanks again for your help.
You are telling that function will return a string but trying to return 0. Use exit to interrupt program execcution or throw your own exception.
BTW is your "no larger than 20 digits" a constraint (tells you that both inputs and result will not be larger than 20 digits so you should not bother about larger numbers) or invariant (that means you should check it)?
Also my "quick and dirty" solution contains a bug. Try adding 99 and 99 to see it. To fix, change my original code:
21 22 23 24 25
}
if (overflow)result.push_back('1');return {result.rbegin(), result.rend()};
}