Summary: std.container.BinaryHeap enforce message + pop
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Phobos

--- Comment #0 from 2011-01-19 14:34:44 PST ---
A D2 program:

import std.container;
void main() {
    auto h = BinaryHeap!(int[])([]);

It throws the exception:
object.Exception@...\dmd\src\phobos\std\container.d(2592): Enforcement failed

In a larger program such error message is bad because it doesn't give a lot of
information. To improve the situation a little I suggest to modify the enforce
at line 2592:

    void removeFront()

Adding an error message that helps understand what the error is:

enforce(!empty, "Attempt to remove the front of an empty heap");

(The future stack trace on Windows will probably also give the line number 4 of
the user program.)


In code that uses the BinaryHeap I've often used two lines of code like this:

auto item = heap.front();

So I suggest to add to BinaryHeap a handy member function pop() that does both
auto item = heap.pop();

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to