Hi.
I want to extend math library functions to work with my own type.
However, the definition for my own type seems to prevent
automated access to the original function. How can I fix this
unexpected behavior?
Simplified example:
--------------------
import std.math;
int exp2(int x) {
return 1 >> x;
}
void main() {
assert(exp2(0.0) == 1.0); // <= why does not
this work anymore?
//assert(std.math.exp2(0.0) == 1.0); // <= this works
}
--------------------

Hi.
I want to extend math library functions to work with my own
type. However, the definition for my own type seems to prevent
automated access to the original function. How can I fix this
unexpected behavior?
Simplified example:
--------------------
import std.math;
int exp2(int x) {
return 1 >> x;
}
void main() {
assert(exp2(0.0) == 1.0); // <= why does not
this work anymore?
//assert(std.math.exp2(0.0) == 1.0); // <= this works
}
--------------------

Hi.
I want to extend math library functions to work with my own
type. However, the definition for my own type seems to prevent
automated access to the original function. How can I fix this
unexpected behavior?
Simplified example:
--------------------
import std.math;
int exp2(int x) {
return 1 >> x;
}
void main() {
assert(exp2(0.0) == 1.0); // <= why does not
this work anymore?
//assert(std.math.exp2(0.0) == 1.0); // <= this works
}
--------------------

It's bug (I forget the exact bug number). TDPL says that you can do it, and as
I understand it, it's simply a question of when someone is going to fix it
(though I have no idea how easy it will be to fix it) and not a question of
whether it'll change or not.
- Jonathan M Davis

I don't think you can overload template methods with non-template methods

You cannot. The usual workaround for this is to make the non-template
method a dummy template:
void foo () (int a) {} // Note the extra pair of empty parentheses
But this won't work if you're not controlling the non-template method.
--
/Jacob Carlborg