3 ms·
I'm assuming here that they would use the `size_type` for the container they are iterating over. Otherwise I'm not sure.
by rleigh 7y ago
I'm assuming here that they would use the `size_type` for the container they are iterating over. Otherwise I'm not sure.
- ncmncm 7y agoAn unsigned type is sometimes a poor choice for a loop index. The compiler then cannot assume the loop will terminate, and generate worse code. Usually this doesn't matter -- until you discover it did.
- rleigh 7y agoGood point. Probably not a problem in practice for most containers, but yet another reason for why the STL (and C library, for that matter) should have used a signed size type from the beginning.
- nitwit005 7y agoYep, it's to match vector/array size_type and difference_type, although I tend to just use size_t and ptrdiff_t directly.