3 ms·
When the rubber meets the road, and I need to write some actual code, I guess I'm not sure what is being recommended here. Say I need to iterate through the ind
by ggchappell 13y ago
When the rubber meets the road, and I need to write some actual code, I guess I'm not sure what is being recommended here. Say I need to iterate through the indices of a vector--his "strongest counterargument". He suggests "casting the unsigneds to signed integers". Am I supposed to do this?
for (ptrdiff_t i = 0; i != ptrdiff_t(v.size()); ++i)
I think the real answer here is for something like Python's itertools to be in the C++ Standard Library, so that we never need to do anything remotely like the code above. But failing that, it isn't clear to me what the "best practices" version of the above would be.