Function hijack on selective import

Adam D. Ruppe destructionator at gmail.com
Tue Dec 26 16:15:55 UTC 2017


The mistake you're making is using a constraint when you should 
try a specialization:


int signbit(T:Custom)(T x)
{
     return 0;
}


That means to use this specialized function when T is Custom. 
Now, you just need to merge the overload sets:

import std.math;
alias signbit = std.math.signbit; // this merges local signbit 
with std.math.signbit


and boom it should compile and call your version.



More information about the Digitalmars-d-learn mailing list