Re: Template argument deduction fails with alias

2020-09-01 Thread Paul Backus via Digitalmars-d-learn
On Tuesday, 1 September 2020 at 02:48:08 UTC, Ben Jones wrote: 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 =

Re: Template argument deduction fails with alias

2020-08-31 Thread Ben Jones via Digitalmars-d-learn
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; } boo

Re: Template argument deduction fails with alias

2020-08-31 Thread Paul Backus via Digitalmars-d-learn
On Tuesday, 1 September 2020 at 01:11:35 UTC, Ben Jones wrote: I have an alias that looks like static if(...){ alias AliasType = SumType!(...); } which I use in a template constraint for a function template: bool func(T: AliasType!Args, Args...)(T t){ ... } When I try to call func with an

Re: Template argument deduction fails with alias

2020-08-31 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/31/20 9:11 PM, Ben Jones wrote: I have an alias that looks like static if(...){   alias AliasType = SumType!(...); } which I use in a template constraint for a function template: bool func(T: AliasType!Args, Args...)(T t){ ... } When I try to call func with an AliasType object, the arg

Template argument deduction fails with alias

2020-08-31 Thread Ben Jones via Digitalmars-d-learn
I have an alias that looks like static if(...){ alias AliasType = SumType!(...); } which I use in a template constraint for a function template: bool func(T: AliasType!Args, Args...)(T t){ ... } When I try to call func with an AliasType object, the argument deduction fails with a message s