On Thursday, 18 October 2012 at 12:10:17 UTC, tn wrote:
On Thursday, 18 October 2012 at 11:43:40 UTC, simendsjo wrote:
On Thursday, 18 October 2012 at 11:31:47 UTC, tn wrote:
(...)
You need to manually add std.math.exp2 to the overload set so
importing external methods doesn't hijack your methods:
http://dlang.org/function.html#overload-sets
alias std.math.exp2 exp2;
Thanks, that clarifies quite a lot. Unfortunately my example
was too simplified, as my type is a template.
This still does not work:
--------------------
import std.math;
struct Lognum(T) {
T lx;
}
T log(T)(Lognum!T x) {
return x.lx;
}
alias std.math.log log;
void main() {
//assert(std.math.log(1.0) == 0.0);
assert(log(1.0) == 0.0);
Lognum!double x;
x.lx = 0.0;
assert(log(x) == 0.0);
}
--------------------
I don't think you can overload template methods with non-template
methods:
void f(string i) {}
void f(T)(T i) if (is(T == double)) {}
void main(string[] args) {
f(2.2);
}
Error: template ol.f(T) if (is(T == double)) conflicts with
function ol.f at ol.d(1)