Closed spillner closed 13 years ago
The problem with this code is that it does the wrong thing on empty collections; i.e, when last == first
To avoid postincrement, it might be better to use a degenerate for loop:
for ( ; first != last; ++first ) if ( !p (*first)) return false; return true;
Changed in commit #4d598e84100b535fbb47bab16db313f4b1107287
do { if (!p(*first) return false; } while (++first != last);
would be more readable and sometimes more efficient (and perhaps even better-supported for some nonstandard iterator types.)