Disabling opAssign in a type disabled all the opAssigns of an aliased type?

aliak something at something.com
Mon Jul 30 20:42:29 UTC 2018


On Monday, 30 July 2018 at 20:38:33 UTC, aliak wrote:
> On Monday, 30 July 2018 at 20:20:15 UTC, Alex wrote:
>> On Monday, 30 July 2018 at 19:33:45 UTC, aliak wrote:
>>> On Monday, 30 July 2018 at 18:47:06 UTC, Alex wrote:
>>>> On Monday, 30 July 2018 at 18:30:16 UTC, aliak wrote:
>>>>> [...]
>>>>
>>>> What happens if you omit the @disable line?
>>>
>>> Compiles ok then.
>>
>> So... is this a valid workaround? ;)
>
> Hehe. Unfortunately not. It's for a proxy type that I need to 
> disallow assignment to. But the proxy type uses alias to a T. 
> So if T has a custom opAssign then bye bye functionality.

The actual code is here if you're curious:

https://github.com/aliak00/optional/pull/16/commits/93d51d790d313be3b108df2bd8b3699adc898bd0

Right now I've only:

@disable this(); // Do not allow user creation of a Dispatcher
@disable this(this) {} // Do not allow blitting either

But I also want to

@disable void opAssign(U)(Dispatcher!U)

So that you can't reassign to the Dispatcher (i.e. proxy type)

But if I do that then the opAssigns in the Optional!T cease 
functioning.



More information about the Digitalmars-d-learn mailing list