A Huge Bummer When Using alias this

Jack Stouffer via Digitalmars-d digitalmars-d at puremagic.com
Thu Mar 24 14:26:00 PDT 2016


alias this is only useful when not using any function that relies 
on the template constraints in std.traits.

For example

import std.traits;

void someFunc(N)(N val) if (isNumeric!N)
{
     int b = val;
}

void main()
{
     import std.typecons;
     Nullable!int a = 42;

     someFunc(a);
}

$ dmd test.d
test.d(13): Error: template someFunc cannot deduce function from 
argument types !()(Nullable!(int))

Removing the template constraint makes it compile and run just 
fine. What's a good work around for these types of issues?


More information about the Digitalmars-d mailing list