T.zero and T.one for numeric types

Biotronic via Digitalmars-d digitalmars-d at puremagic.com
Fri Apr 17 07:33:56 PDT 2015


On Friday, 17 April 2015 at 13:33:36 UTC, Adam D. Ruppe wrote:
> On Friday, 17 April 2015 at 13:27:19 UTC, Biotronic wrote:
>>   void foo(T)(T a) {}
>>
>>   foo!T(0);
>
> Does foo(T(0)); work? It seems like it should
>
>
> void foo(T)(T a) {}
> import std.bigint;
> import std.complex;
> void main() {
>         foo(BigInt(0));
>         foo(float(0));
>         foo(int(0));
>         foo(Complex!float(0));
> }
>
>
> as of one of the newish dmds, T(n) works to construct basic 
> types too.

Man, that actually does work. I guess I've become too used to it 
not. Sorry about the noise then, and thanks!


More information about the Digitalmars-d mailing list