www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Why this simple binaryHeap program does not compile?

reply Cheng Wei <rivercheng gmail.com> writes:
import std.container;

class T {
    int i;
}

void main() {
    auto array = Array!(T);
    auto heap  = BinaryHeap!(Array!(T), "a.i < b.i")(array);
}

After compiling:
dmd2/linux/bin32/../../src/phobos/std/container.d(1612): Error:
template std.conv.emplace(T) if (!is(T == class)) does not match any
function template declaration
dmd2/linux/bin32/../../src/phobos/std/container.d(1612): Error:
template std.conv.emplace(T) if (!is(T == class)) cannot deduce
template function from argument types !()(T*,T)


Is this a bug or I use the binary heap wrongly? Thanks a lot!
Sep 22 2011
parent reply Ellery Newcomer <ellery-newcomer utulsa.edu> writes:
On 09/22/2011 06:10 AM, Cheng Wei wrote:
 
 Is this a bug or I use the binary heap wrongly? Thanks a lot!

Looks like a bug in Array. emplace doesn't accept a pointer to a chunk for class types. Report that puppy!
Sep 22 2011
parent David Nadlinger <see klickverbot.at> writes:
On 9/22/11 7:20 PM, Ellery Newcomer wrote:
 Looks like a bug in Array. emplace doesn't accept a pointer to a chunk
 for class types.

 Report that puppy!

See https://github.com/D-Programming-Language/phobos/commit/65a0c2158b1d2ea8e9d3094746739da636266089. David
Sep 22 2011