Compile this and see, (it's crazy!):
import std.stdio;
struct Widget {
private int[] array;
this(uint length) {
array = new int[length];
}
this(this) {
writeln( "this(this) called" );
array = array.dup;
}
Simplified:
import std.stdio;
struct Widget {
private int[] array;
this(uint length) {
array = new int[length];
writefln("ctor called : %s", array.ptr);
}
this(this) {
writef( "this(this) called: %s", array.ptr );
array = array.dup;
wr
On 01/21/2017 03:19 PM, Ali Çehreli wrote:
this(this) {
TIL! Change the signature and it works without copies:
this(const(this)) {
// ...
}
How did I miss this for so long?
Ali
On 01/21/2017 03:36 PM, Ali Çehreli wrote:
> Change the signature and it works without copies:
>
> this(const(this)) {
> // ...
> }
Ugh... :( It's not a post-blit. Then what is it?
Ali
On Sunday, 22 January 2017 at 00:31:38 UTC, Ali Çehreli wrote:
On 01/21/2017 03:36 PM, Ali Çehreli wrote:
> Change the signature and it works without copies:
>
> this(const(this)) {
> // ...
> }
Ugh... :( It's not a post-blit. Then what is it?
Ali
This is a __ctor that takes
On 01/21/2017 07:22 PM, Basile B. wrote:
On Sunday, 22 January 2017 at 00:31:38 UTC, Ali Çehreli wrote:
On 01/21/2017 03:36 PM, Ali Çehreli wrote:
> Change the signature and it works without copies:
>
> this(const(this)) {
> // ...
> }
Ugh... :( It's not a post-blit. Then what
On Sunday, 22 January 2017 at 03:42:21 UTC, Ali Çehreli wrote:
On 01/21/2017 07:22 PM, Basile B. wrote:
[...]
Wow! Thanks.
I know about 'alias this' but this (pun!) is new to me. TIL
indeed and WAT (four exclamation marks is right in this
case. :o) )
import std.stdio;
struct S {