Boost logo

Boost :

From: Jeremy Siek (jsiek_at_[hidden])
Date: 2001-08-07 15:05:08

Here's a suggestion for the style guide.

I was recently bitten by a peice of code originally written like this:

for (int i = c.size()-1; i >= 0; --i)

because the code was later changed to this

typedef ... size_type;
for (size_type i = c.size()-1; i >= 0; --i)

and then stopped working since an unsigned int is always >= 0.

So the moral of the story is that reverse_iterator's and rbegin()/rend()
are the better way to go when traversing a container in reverse.


 Jeremy Siek www:
 Ph.D. Candidate, IU B'ton email: jsiek_at_[hidden]
 Summer Manager, AT&T Research phone: (973) 360-8185

Boost list run by bdawes at, gregod at, cpdaniel at, john at