Created
February 1, 2014 01:04
-
-
Save pontifechs/8746471 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import std.stdio; | |
class Foo(uint something) | |
{ | |
Foo opBinary(string op)(Foo rhs) const | |
if (op == "*") | |
{ | |
writeln("calling Foo.*"); | |
} | |
} | |
class Bar : Foo!(3) | |
{} | |
class Baz : Foo!(4) | |
{} | |
void main() | |
{ | |
auto bar = new Bar(); | |
auto baz = new Baz(); | |
auto foo = bar * baz; | |
// errors with | |
// tinker.d(25): Error: 'cast(Object)bar' is not of arithmetic type, it is a object.Object | |
// tinker.d(25): Error: 'baz' is not of arithmetic type, it is a tinker.Baz | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment