What's wrong with this BinaryHeap declaration line? Assertion failure in std.container.array.d

Enjoys Math via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Sep 22 22:56:06 PDT 2015


What I HAD TO do to get it to compile:

programResultsQ = heapify!(compareResults, 
Array!(Results!(O,I)))(Array!(Results!(O,I))([Results!(O,I)()]), 
1);
programResultsQ.popFront();

What running it says:

AssertionFailure at line 381 of std.container.array.d, which 
looks like:

/**
Constructor taking a number of items
      */
     this(U)(U[] values...) if (isImplicitlyConvertible!(U, T))
     {
         import std.conv : emplace;
         auto p = cast(T*) malloc(T.sizeof * values.length);
         static if (hasIndirections!T)
         {
             if (p)
                 GC.addRange(p, T.sizeof * values.length);
         }

         foreach (i, e; values)
         {
             emplace(p + i, e);
             assert(p[i] == e);     /* THIS IS LINE 381 */
         }
         _data = Data(p[0 .. values.length]);
     }

Any ideas.  How can I improve this declaration?  Using Phobos 
sometimes is such a mystery.




More information about the Digitalmars-d-learn mailing list