Properties and Copy Constructors
Steven Schveighoffer
schveiguy at yahoo.com
Mon Aug 10 07:25:59 PDT 2009
On Thu, 06 Aug 2009 18:08:00 -0400, Chad J
<chadjoan at __spam.is.bad__gmail.com> wrote:
> So I dug up Andrei's thread that mentioned something about properties
> that hasn't been discussed as of recent: expensive copy semantics.
>
...
> Towards the end of the discussion Steven Schveighoffer mentioned that
> this need to acquire and release is dictated by the type being used in
> the property, not by the property itself. Thus it is the type's
> responsibility to make decisions about how it should be
> moved/swapped/acquired/released.
...
>
> Now I'm assuming the ref return and ref passing of these BigInts doesn't
> invoke their copy-constructors. Is there any reason this can't work?
Yeah, I think that's exactly what I was thinking. If a struct controls
its copy semantics, you can avoid aliasing problems, and use reference
properties for doing swap-like operations.
-Steve
More information about the Digitalmars-d
mailing list