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)`