3 ms·
No, it's not. The check is done before the loop, so i has the correct value inside the loop. Still, the trick makes it look suspect and that's an argument agai
by shdon 12y ago
No, it's not. The check is done before the loop, so i has the correct value inside the loop.
Still, the trick makes it look suspect and that's an argument against using it.
- Aldo_MX 12y ago> Still, the trick makes it look suspect and that's an argument against using it. This is true. The code is confusing to people not used to it. A workaround could be to hide this code inside a macro, so people not interested in digging into the code would take the macro's word: #define REVERSE_LOOP( x, i ) for( size_t i = x.size(); i-- > 0; ) But unfortunately, that doesn't help with the fear that people has against unsigned types.