Re: NoCopy for overriding @disable this(this)

2018-04-15 Thread Eduard Staniloiu via Digitalmars-d

On Thursday, 12 April 2018 at 17:09:22 UTC, Shachar Shemesh wrote:

On 12/04/18 18:42, Uknown wrote:
On Thursday, 12 April 2018 at 12:16:53 UTC, Shachar Shemesh 
wrote:

[...]


The problem seems to be that cast is happening at compile 
time, as opposed to run time, as you might have already 
figured out. Do you need to really do this cast at compile 
time? I tried running the snippet you gave here: 
https://run.dlang.io/is/im19nL


Is this how you intend for it to be used? Then there's no need 
for compile time casts. If not, could you give an example of 
how `NoCopy` would be used?


struct Disabled {
  int i = 17;

  @disable this(this);
}

struct Container {
  NoCopy!Disabled disabled;
}

Any instance you create of "Container" will have i initialized 
to 0 by default.


Since `T` has the postblit disabled, I'm guessing the ctor should 
take a `ref T`.


Since `T` has the postblit disabled, I'm guessing the ctor should 
take a `ref T`.





Re: NoCopy for overriding @disable this(this)

2018-04-12 Thread Shachar Shemesh via Digitalmars-d

On 12/04/18 18:42, Uknown wrote:

On Thursday, 12 April 2018 at 12:16:53 UTC, Shachar Shemesh wrote:

[...]
test.d(19): Error: cannot convert  to const(ubyte*) at compile time
[...]
Thank you,
Shachar


The problem seems to be that cast is happening at compile time, as 
opposed to run time, as you might have already figured out. Do you need 
to really do this cast at compile time? I tried running the snippet you 
gave here: https://run.dlang.io/is/im19nL


Is this how you intend for it to be used? Then there's no need for 
compile time casts. If not, could you give an example of how `NoCopy` 
would be used?


struct Disabled {
  int i = 17;

  @disable this(this);
}

struct Container {
  NoCopy!Disabled disabled;
}

Any instance you create of "Container" will have i initialized to 0 by 
default.


Re: NoCopy for overriding @disable this(this)

2018-04-12 Thread Uknown via Digitalmars-d

On Thursday, 12 April 2018 at 12:16:53 UTC, Shachar Shemesh wrote:

[...]
test.d(19): Error: cannot convert  to const(ubyte*) at 
compile time

[...]
Thank you,
Shachar


The problem seems to be that cast is happening at compile time, 
as opposed to run time, as you might have already figured out. Do 
you need to really do this cast at compile time? I tried running 
the snippet you gave here: https://run.dlang.io/is/im19nL


Is this how you intend for it to be used? Then there's no need 
for compile time casts. If not, could you give an example of how 
`NoCopy` would be used?