[Issue 12918] Copying-constructing structs onto the heap

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sun Jun 15 14:25:14 PDT 2014


https://issues.dlang.org/show_bug.cgi?id=12918

Matt Kline <mkline.on.d at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mkline.on.d at gmail.com

--- Comment #3 from Matt Kline <mkline.on.d at gmail.com> ---
(In reply to bearophile_hugs from comment #1)

> What are some use cases of code like that?

Say struct Foo has a member Bar* b, which can either contain some optional data
or be null to indicate that no such data is currently present.

>From some other data structure, you procure an instance of Bar (call it other)
which you would like to assign to b. However, to make the lifetime of b
independent of its source, you want to create a garbage-collected copy of other
and assign it to b.

--


More information about the Digitalmars-d-bugs mailing list