Struct copies
Stanislav Blinov
stanislav.blinov at gmail.com
Tue Jan 28 02:17:55 PST 2014
On Tuesday, 28 January 2014 at 01:39:47 UTC, bearophile wrote:
> Stanislav Blinov:
>
>> Generally though, pure code generation issues aside, that is
>> one very strange swap function, bearophile :)
>
> What's strange on this?
>
>
> void swap(T)(ref T x, ref T y) pure nothrow {
> immutable aux = x;
> x = y;
> y = aux;
> }
Won't swap references or pointers (due to immutable) or structs
with disabled postblit (due to assignment). Solution to first is
simple: immutable -> auto. Second would basically require you to
perform memcpy manually anyway.
More information about the digitalmars-d-ldc
mailing list