Re: struct on heap with std.experimental.allocator

2016-06-07 Thread jmh530 via Digitalmars-d-learn
On Tuesday, 7 June 2016 at 15:43:34 UTC, Adam D. Ruppe wrote: On Tuesday, 7 June 2016 at 15:39:59 UTC, jmh530 wrote: My sense is that putting it on the GC heap gives the struct reference semantics. It doesn't matter what heap it is on, you are just using a pointer here. Struct pointers in

Re: struct on heap with std.experimental.allocator

2016-06-07 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 7 June 2016 at 15:39:59 UTC, jmh530 wrote: My sense is that putting it on the GC heap gives the struct reference semantics. It doesn't matter what heap it is on, you are just using a pointer here. Struct pointers in D will automatically dereference with a.x, so no need for the

struct on heap with std.experimental.allocator

2016-06-07 Thread jmh530 via Digitalmars-d-learn
I modified one of the first examples from std.experimental.allocator to put a struct on the heap (below). My sense is that putting it on the GC heap gives the struct reference semantics. I was struck by two things. First, I didn't have to use (*a).x, I could just use a.x. Also, when I assign