On Friday, 12 February 2016 at 05:51:34 UTC, Meta wrote:
If you try to compile this code, it will currently not work:

foreach (n; iota(1UL, 1000).parallel)
{
    //...
}


This is because of how the length is calculated by iota:

auto iota(B, E)(B begin, E end)
if (isIntegral!(CommonType!(B, E)) || isPointer!(CommonType!(B, E)))
{
    import std.conv : unsigned;

    //...

    //The return type of length. When either begin or end
    //is ulong, then IndexType == ulong
    alias IndexType = typeof(unsigned(end - begin));

    static struct Result
    {
        private Value current, pastLast;

        //...

        @property IndexType length() const
        {
            return unsigned(pastLast - current);
        }
    }

    return Result(begin, end);
}


And because std.parallelism.TaskPool.defaultWorkUnitSize takes a size_t, which with a 32-bit DMD is uint.

What I want to know is, is this considered a bug? If so I will submit a pull request to fix it.

I made a pull request: https://github.com/D-Programming-Language/phobos/pull/4013
  • Re: Weird issue with std.range.... Meta via Digitalmars-d

Reply via email to