www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 17616] New: makeIndex cannot fully use range of index type


          Issue ID: 17616
           Summary: makeIndex cannot fully use range of index type
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: code dawg.eu

cat > bug.d << CODE
void main()
    import std.algorithm, std.range;

    ubyte[256] index = void;
dmd -run bug
object.Exception /usr/include/dmd/phobos/std/algorithm/sorting.d(997): Cannot
create an index with element type ubyte with length 256.

The maximum index value for a range of length 256 is 255, which fits nicely
into a ubyte.
makeIndex should support converting a full range of e.g. ubyte[256] or
ushort[65536] into an index of ubyte[256] or ushort[65536] as it's a nice way
to obtain a bijective inverse mapping of such a range.

Jul 07 2017