A Huge Bummer When Using alias this

deadalnix via Digitalmars-d digitalmars-d at puremagic.com
Thu Mar 24 17:13:41 PDT 2016


On Thursday, 24 March 2016 at 22:52:20 UTC, Jack Stouffer wrote:
> You just illustrated my point exactly. This doesn't scale, you 
> can't create special rules for every type when you're writing a 
> library. Nullable is aliased to the get function, which returns 
> int in this case. YOU SHOULDN'T HAVE TO DO THIS.
>
> This is the exact use case of alias this and it doesn't work.

Thing is, this is because of the constraint you use. Constraints 
that test capabilities would work, as well as constraints that 
check coercability.

If you want to check for something that convert to an integral, 
rather than check if it ACTUALLY IS an integral, just use is(T : 
int) in your case.



More information about the Digitalmars-d mailing list