Issue with template constraints in numeric types

data pulverizer via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Aug 3 05:49:48 PDT 2017


On Thursday, 3 August 2017 at 12:35:08 UTC, data pulverizer wrote:
> What about this case:
>
> ```
> T test(T: double)(T x, T y)
> {
> 	return x*y;
> }
>
> auto test(T)(T x, T y)
> {
> 	return 5*test!double(x, y);
> }
> ```
>
> which also gives:
>
> ```
> int test: 4
> double test: 4
> ```

Hmm ... it looks as the specialization `:` operator is working 
like the constraint `:` operator and doing convertible at least 
for the floating point case. Is that right?


More information about the Digitalmars-d-learn mailing list