Template argument deduction fails with alias
Ben Jones
fake at fake.fake
Tue Sep 1 02:48:08 UTC 2020
On Tuesday, 1 September 2020 at 01:26:30 UTC, Paul Backus wrote:
>
> Aside from using SumType directly in the function signature,
> another workaround is to use a wrapper struct instead of an
> alias:
>
> struct AliasType(Args...) {
> SumType!Args data;
> alias data this;
> }
>
> bool func(T : AliasType!Args, Args...)(T t) { ... }
Thanks all.
I tried using alias this at first and then I get errors trying to
construct AliasType objects:
auto pi = Payload!int(5);
auto pe = ParseError("error");
alias PRType = ParseResult!(Payload!int, ParseError);
auto pr = PRType(pi);
gives:
cannot implicitly convert expression `pi` of type `Payload!int`
to `SumType!(Payload!int, ParseError)`
More information about the Digitalmars-d-learn
mailing list