4 ms·
I would prefer to use auto when iterating through the container, certainly. But much of the code I write is numerical stuff and "i" really is logically an integ
by cannam 12y ago
I would prefer to use auto when iterating through the container, certainly. But much of the code I write is numerical stuff and "i" really is logically an integer rather than an iterator, arising as the result of some actual arithmetic.
I find I have to do this quite often, and I'm not going to write static_cast<int>() every time.
Yes, I can see why this isn't a good idea -- I'm pained by it myself. I'm just wondering what I might have overlooked among the possibilities available for this kind of code.
- shin_lao 12y agoIf you are writing numerical stuff, you should be using more explicit types such as std::uint32_t.