std.sumtyp and option ?
jmh530
john.michael.hall at gmail.com
Thu Jun 29 15:20:29 UTC 2023
On Thursday, 29 June 2023 at 14:18:05 UTC, kiriakov wrote:
> How to create option type over std.sumtype ?
>
>
> ```
> enum None;
> struct Some(T) { T x; }
> alias Option = SumType!(Some!T, None);
> ```
> I get
> Error: undefined identifier `T`
Try
```d
alias Option(T) = SumType!(Some!T, None);
```
Your version of `Option` isn't a template, so it doesn't know
what `T` is. This version uses the eponymous template syntax for
aliases.
More information about the Digitalmars-d-learn
mailing list