Re: SumType alias can't be deduced?

2022-02-21 Thread Emmanuelle via Digitalmars-d-learn
On Monday, 21 February 2022 at 20:18:46 UTC, Paul Backus wrote: This is a long-standing limitation of the D compiler's template argument deduction: it cannot "see through" `alias` templates to deduce the underlying type. Oh, that’s an unfortunate limitation but at least there’s a workaround.

Re: SumType alias can't be deduced?

2022-02-21 Thread Paul Backus via Digitalmars-d-learn
On Monday, 21 February 2022 at 18:43:18 UTC, Emmanuelle wrote: If you run this, the compiler should emit this error: ```d onlineapp.d(14): Error: template `onlineapp.foobar` cannot deduce function from argument types `!()(SumType!(int, Unit))` onlineapp.d(8):Candidate is: `foobar(T)(Opt

SumType alias can't be deduced?

2022-02-21 Thread Emmanuelle via Digitalmars-d-learn
See https://run.dlang.io/is/hNaSFh: ```d import std.sumtype; struct Unit {} alias Option(T) = SumType!(T, Unit); void foobar(T)(Option!T option) {} void main() { foobar(Option!int(123)); } ``` If you run this, the compiler should emit this error: ```d onlineapp.d(14): Error: template `on