Why would it fail? Wouldn't it just do nothing? Or is it because v.size()-1 presumably is unsigned since it's being compared against a size_t so it would run MAX_INT times?
Because size() returns a size_t, which is unsigned. And (unsigned)-1 is a very, very large number...
The first one is an uint16, which presumably, a 16-bit integer whose maximum value is 65536. That loop iterates 70000 times.
The second one is the conditional i < size()-1. The last element won't get counted for. And of course, if size() returns 0, it will evaluate to a very large number.
Trying to work on something while way past too tired to program, but I needed to get something done that I could actually show someone.
started with for x in a:
for y in a:
# Do something with x[0] ... y[1]
#A short time later...
for x in a:
#Do something else x[0] .... y[1]
Also managed to screw myself over trying to hunt down a bug over position 1 vs 0 of a list. Translating some notes written by someone else into code can be dangerous. The issue was so hard to track because for most of the data set had the same value in the first two elements of the list, except for a few rare cases.
Old Username: Talroth
If your signature on a web forum takes up more space than your average post, then you are doing things wrong.
I did this a few nights back, I was up really late playign around with JavaScript and the Canvas HTML Element and for some reason needed to test if something was odd or even...