News for hackers. Stuff that matters.
Re:Bounded Integer: Header-only C++ library replaces integer... by rleigh on Sunday September 29, 2019 @01:39PM (#21108408)
I'm assuming here that they would use the `size_type` for the container they are iterating over. Otherwise I'm not sure.
Re:Bounded Integer: Header-only C++ library replaces integer... by ncmncm on Sunday September 29, 2019 @03:27PM (#21109132)
An 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.
Re:Bounded Integer: Header-only C++ library replaces integer... by rleigh on Sunday September 29, 2019 @03:42PM (#21109231)
Good 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.
Re:Bounded Integer: Header-only C++ library replaces integer... by nitwit005 on Sunday September 29, 2019 @06:10PM (#21109928)
Yep, it's to match vector/array size_type and difference_type, although I tend to just use size_t and ptrdiff_t directly.