Re: How to require operator overloading in interface

2013-07-21 Thread JS
On Saturday, 20 July 2013 at 19:04:29 UTC, Jesse Phillips wrote: On Saturday, 20 July 2013 at 18:53:44 UTC, JS wrote: if they want to allow the same op in there class, which they probably do, they have to override the long hand anyways and redirect. Nope, that is why you make the template fin

Re: How to require operator overloading in interface

2013-07-20 Thread Jesse Phillips
On Saturday, 20 July 2013 at 18:53:44 UTC, JS wrote: if they want to allow the same op in there class, which they probably do, they have to override the long hand anyways and redirect. Nope, that is why you make the template final and forwards, all derived classes will be able to instantiate

Re: How to require operator overloading in interface

2013-07-20 Thread JS
On Saturday, 20 July 2013 at 18:34:30 UTC, Jesse Phillips wrote: On Saturday, 20 July 2013 at 16:46:52 UTC, JS wrote: class MyClass { auto opBinary(string op : "|" T : int)(T t) { } // opBinary is completely specialized and is no different than a regular f

Re: How to require operator overloading in interface

2013-07-20 Thread Jesse Phillips
On Saturday, 20 July 2013 at 16:46:52 UTC, JS wrote: class MyClass { auto opBinary(string op : "|" T : int)(T t) { } // opBinary is completely specialized and is no different than a regular function, it can be overridden directly in children without havin

Re: How to require operator overloading in interface

2013-07-20 Thread JS
On Saturday, 20 July 2013 at 13:27:03 UTC, H. S. Teoh wrote: On Sat, Jul 20, 2013 at 12:13:49PM +0200, JS wrote: On Saturday, 20 July 2013 at 01:37:13 UTC, Jesse Phillips wrote: >The relevant blog post: > >http://3d.benjamin-thaut.de/?p=94 > >What you should understand is template functions are

Re: How to require operator overloading in interface

2013-07-20 Thread H. S. Teoh
On Sat, Jul 20, 2013 at 12:13:49PM +0200, JS wrote: > On Saturday, 20 July 2013 at 01:37:13 UTC, Jesse Phillips wrote: > >The relevant blog post: > > > >http://3d.benjamin-thaut.de/?p=94 > > > >What you should understand is template functions are not/can not > >be virtual. They do not exist until t

Re: How to require operator overloading in interface

2013-07-20 Thread JS
On Saturday, 20 July 2013 at 01:37:13 UTC, Jesse Phillips wrote: The relevant blog post: http://3d.benjamin-thaut.de/?p=94 What you should understand is template functions are not/can not be virtual. They do not exist until they are instantiated. Thus you can not require that they be overload

Re: How to require operator overloading in interface

2013-07-19 Thread Jesse Phillips
The relevant blog post: http://3d.benjamin-thaut.de/?p=94 What you should understand is template functions are not/can not be virtual. They do not exist until they are instantiated. Thus you can not require that they be overloaded.

Re: How to require operator overloading in interface

2013-07-19 Thread H. S. Teoh
On Fri, Jul 19, 2013 at 04:28:42PM +0200, Adam D. Ruppe wrote: > You can't have templates in interfaces unless they are final, > otherwise it won't work right. > > The way I'd do it is is make the op template final, and have it > forward to another normal virtual function: > > interface Addable {

Re: How to require operator overloading in interface

2013-07-19 Thread Adam D. Ruppe
You can't have templates in interfaces unless they are final, otherwise it won't work right. The way I'd do it is is make the op template final, and have it forward to another normal virtual function: interface Addable { final Addable opBinary(string op : "+")(Addable rhs) { return

How to require operator overloading in interface

2013-07-19 Thread JS
I would like to require any implementation of an interface to override import std.stdio, std.cstream; interface A { void opOpAssign(string op : "^")(int c); } class B : A { int x; void opOpAssign(string op : "+")(int c) { x = c; } // Note it uses + } void main(