February 27, 2019 How can we template an alias? | ||||
---|---|---|---|---|
| ||||
doubles and ints are not upcasted properly to complex foo(Complex!double c) foo(3) fails I'd like to do something like alias CR(t) = Complex!double(t); CR(3) which would be equivalent to typing Complex!double(3) but much shorter. Writing a wrapper is overkill. |
February 27, 2019 Re: How can we template an alias? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Michelle Long | On Wednesday, 27 February 2019 at 04:11:09 UTC, Michelle Long wrote:
> doubles and ints are not upcasted properly to complex
> foo(Complex!double c)
>
> foo(3) fails
>
> I'd like to do something like
>
> alias CR(t) = Complex!double(t);
>
>
> CR(3)
>
> which would be equivalent to typing Complex!double(3) but much shorter.
>
> Writing a wrapper is overkill.
I guess I oversimplied...
alias C = Complex!double;
then C(3) works fine.
My problem is slightly more complex but I haven't figured out how to reduce it.
|
Copyright © 1999-2021 by the D Language Foundation