does pointer refer to a heap object?
Carl Sturtivant
sturtivant at gmail.com
Sat Jul 27 11:19:18 PDT 2013
>
> import core.memory, std.stdio;
>
> struct A { }
>
> void main()
> {
> A a;
> auto ap = &a;
>
> auto bp = new A;
>
> writeln("ap", GC.addrOf(ap) ? "" : " not", " allocated with
> the GC");
> writeln("bp", GC.addrOf(bp) ? "" : " not", " allocated with
> the GC");
> }
>
>
> Note that the heap is more than just GC allocated memory. C
> malloc allocates on the heap but would fail the above test (as
> it should).
Nice, does what I need. Thanks.
More information about the Digitalmars-d-learn
mailing list