spir <denis.s...@gmail.com> wrote:
There is a point I don't understand here: Iota is a range-struct
template, with
void popFront()
{
current += step;
}
So, how does the computation of an arbitrary element at a given index
affect looping speed? For mappings (and any kind of traversal, indeed),
there should be an addition per element. Else, why define a range
interface at all? What do I miss?
With floating-point numbers, the above solution does not always work. If
step == 1, increasing current by step amount will stop working at some
point, at which the range will then grind to a halt. If instead one
multiplies step by the current number of steps taken, and adds to the
origin, this problem disappears.
As an example of when this problem shows up, try this code:
float f = 16_777_216;
auto f2 = f + 1;
assert( f == f2 );
The assert passes.
--
Simen