Operator Overloading / Templates
M Cardoso
M_member at pathlink.com
Sun Jul 2 14:42:11 PDT 2006
Is there any way to do templated operator overloading in D? That is something
like the following C++ code:
template< class T >
class Test {
...
template< class U >
Test operator+= ( Test<U> t ) {
...
}
..
};
int main() {
Test<double> u;
Test<float> v;
u += v;
}
In D I would try something like this:
class Test(T) {
...
Test opAddAssign(U)( Test!(U) t) {
...
}
.
}
or
class Test(T) {
...
template(U) opAddAssign {
Test opAddAssign( Test!(U) t ) {
...
}
}
}
But it seems to not work.
More information about the Digitalmars-d
mailing list