Template types in parameter lists
bearophile
bearophileHUGS at lycos.com
Fri Jan 31 17:24:19 PST 2014
Matthew Dudley:
> I'm still fairly new to D, and my google-fu has failed me. I
> don't understand this error.
You have to remember that an instantiated template creates a
totally distinct type.
There are few different ways to face your problem, this is one of
them:
import std.stdio;
class Foo(uint N) {
Foo opBinary(string op, uint N2)(Foo!N2 rhs) const
if (op == "*") {
"calling Foo.*".writeln;
return new Foo;
}
}
class Bar: Foo!3 {}
class Baz: Foo!4 {}
void main() {
auto bar = new Bar;
auto baz = new Baz;
auto foo = bar * baz;
}
Bye,
bearophile
More information about the Digitalmars-d-learn
mailing list