Issue with template constraints in numeric types

Adam D. Ruppe via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Aug 3 05:31:00 PDT 2017


On Thursday, 3 August 2017 at 12:24:02 UTC, data pulverizer wrote:
> import std.traits: isIntegral, isNumeric;

Are you familiar with isFloatingPoint?

http://dpldocs.info/experimental-docs/std.traits.isFloatingPoint.html

> if(is(T: double) && isNumeric!T)

Keep in mind that T:double here means "if T can implicitly 
convert to double". Since int can implicitly convert to double 
too, this case covers both families!

You might want to try == instead of : for a more exact match.


More information about the Digitalmars-d-learn mailing list