NoCopy for overriding @disable this(this)
Shachar Shemesh
shachar at weka.io
Thu Apr 12 17:09:22 UTC 2018
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 &S 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.
More information about the Digitalmars-d
mailing list