[Issue 8520] Simple "in"-constrained opBinaryRight in interface doesn't work

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Aug 8 03:15:22 PDT 2012


http://d.puremagic.com/issues/show_bug.cgi?id=8520



--- Comment #2 from Alex Rønne Petersen <alex at lycus.org> 2012-08-08 12:15:19 CEST ---
(In reply to comment #1)
> Your understanding is wrong - templates never go in the vtable.
> 
> The solution is to use NVI and forwarding:
> 
> interface I
> {
>     int* opBinaryRight_in(int i);
> 
>     int* opBinaryRight(string op : "in")(int i)
>     {
>         return opBinaryRight_in(i);
>     }
> }
> 
> class C : I
> {
>     int* opBinaryRight_in(int i)
>     {
>         return null;
>     }
> }

I could understand if the opBinaryRight template wasn't constrained to "in",
but it is, so I see no reason why it cannot be in the vtable since it can only
ever have one instance in a class.

The NVI solution works, but it's very ugly.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list