On Monday, 22 July 2013 at 03:47:36 UTC, JS wrote:
Doing simple stuff likefor(int i = 0; i < s.length - 1; i++) fails catastrophically if s is empty. To make right one has to reduce performance by writing extra checks.
Not really, you could instead just write your loop correctly. 1. Don't loop on int, you are handling a size_t. 2. Avoid substractions when handling unsigned. for(size_t i = 0; i + 1 < s.length; i++) Problem solved?