News for hackers. Stuff that matters.
Re:C++ Internals: STL Vector, Part 3 by fauigerzigerk on Monday August 10, 2015 @04:14AM (#10033295)
It's not the most concise way to iterate over a sequence of numbers from 1 to 9. Worse than that, it suggests that there may be a number missing somewhere in the middle. You have to scan the entire sequence with your eyes to be sure.

  for (int i = 1; i <= 9; ++i)
is both more concise and requires less thinking to know what's going on.
Re:C++ Internals: STL Vector, Part 3 by sjolsen on Monday August 10, 2015 @07:00PM (#10038027)
That the data he chose can be expressed as a range is utterly inconsequential. The values are never even used. In all likelihood, the author just wrote

    for (auto item : {})
and then filled in the first sequence of numbers that popped into his head.
Re:C++ Internals: STL Vector, Part 3 by fauigerzigerk on Tuesday August 11, 2015 @08:40AM (#10040531)
>That the data he chose can be expressed as a range is utterly inconsequential

It could be, but we don't know that. And that's exactly my point. The syntax he uses forces us to think and even speculate about that. So for the particular sequence he chose for his example, it would be less ambiguous to generate the range algorithmically.