Skip to content

Instantly share code, notes, and snippets.

@pontifechs
Created February 1, 2014 01:04
Show Gist options
  • Save pontifechs/8746471 to your computer and use it in GitHub Desktop.
Save pontifechs/8746471 to your computer and use it in GitHub Desktop.
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