How can I use heapify in @safe code?
Burt via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat Oct 1 09:59:18 PDT 2016
Hi,
I'd like to use a binary heap from @safe code. I thought @safe is
transitive but the following example does not compile:
import std.container.binaryheap;
@safe // This makes things fail.
unittest
{
// Test range interface.
import std.algorithm.comparison : equal;
int[] a = [4, 1, 3, 2, 16, 9, 10, 14, 8, 7];
auto h = heapify(a);
assert(h.equal([16, 14, 10, 9, 8, 7, 4, 3, 2, 1]));
}
Is there a way to @safely call heapify? How?
Thanks in advance!
More information about the Digitalmars-d-learn
mailing list