templated isNaN
Paolo Invernizzi
paolo.invernizzi at gmail.com
Sat Aug 24 04:53:33 PDT 2013
Someone can suggest me a convenient way to declare an 'isNaN'
templated function that plays well with the 'standard.math.isNaN'?
The target is to be able to define isNaN functions for my custom
structures, and I want to keep the same name...
---
import std.math;
bool isNaN(T)(T t) if(is(T==string)){ return true; }
// that is really necessary? What if I have my isNaN in different
modules? Must duplicate?
// bool isNaN(T)(T t) if(is(T:real)) { return std.math.isNaN(t); }
void foo(){
bool b = isNaN(0.0);
}
/d471/f783.d(9): Error: template f783.isNaN does not match any
function template declaration. Candidates are:
/d471/f783.d(3): f783.isNaN(T)(T t) if (is(T == string))
/d471/f783.d(9): Error: template f783.isNaN(T)(T t) if (is(T ==
string)) cannot deduce template function from argument types
!()(double)
---
Thanks in advance!
- Paolo Invernizzi
More information about the Digitalmars-d-learn
mailing list