Difficulties with std.variant.Algebraic

Meta jared771 at gmail.com
Thu Jul 11 05:05:48 PDT 2013


On Thursday, 11 July 2013 at 04:03:19 UTC, Jesse Phillips wrote:
> On Thursday, 11 July 2013 at 03:06:39 UTC, Meta wrote:
>> struct Option(T)
>> {	
>>    Algebraic!(Some!T, None) payload;
>>
>>    alias payload this;
>> }
>
> This is untested but it probably looks something like this:
>
>
> private alias MaybeType = Algebraic!(Some!T, None);
>
> Option!int ans;
> ans.payload = MaybeType(None);

Ideally, payload would be private, and only exposed through alias 
this. It's somewhat unfortunate that this is necessary in the 
first place. D doesn't happen to have something like an 
opImplicitCast, does it?


More information about the Digitalmars-d-learn mailing list