[Issue 6959] New: std.container's BinaryHeap doesn't work with Array!(T)

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Nov 16 06:27:52 PST 2011


http://d.puremagic.com/issues/show_bug.cgi?id=6959

           Summary: std.container's BinaryHeap doesn't work with Array!(T)
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody at puremagic.com
        ReportedBy: zetetyck at gmail.com


--- Comment #0 from zetetyck at gmail.com 2011-11-16 06:27:06 PST ---
The documentation of BinaryHeap in std.container says that:
"If Store is a range, the BinaryHeap cannot grow beyond the size of that range.
If Store is a container that supports insertBack, the BinaryHeap may grow by
adding elements to the container."

But the Array!(T) container, which does have a insertBack() method, can't be
used with a BinaryHeap, as the following code:

import std.container;
void main() {
  auto array = Array!(int)();
  auto heap  = heapify(array);
  //auto heap = BinaryHeap!(Array!(int))(array); // gives same error
}

Gives the following compilation error:
\phobos\std\container.d(2660): Error: this._store()[this._length()] is not an
lvalue

This happens to make growable BinaryHeaps impossible using only Phobos
containers.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list