Automatic Interface Implementation

JS js.mdnq at gmail.com
Fri Jul 5 16:56:58 PDT 2013


On Friday, 5 July 2013 at 23:22:23 UTC, Vladimir Panteleev wrote:
> On Friday, 5 July 2013 at 22:43:06 UTC, JS wrote:
>> std.typecon has a lot of goodies in it but it seems to 
>> re-implement much of the same functionality in many of the 
>> templates.
>
> I agree, it would be nice if it would be broken up into 
> smaller, reusable pieces that would also be usable from user 
> code for tasks such as yours.
>
>> wrap did not compile do I took out the stuff that didn't work 
>> and hacked it up to get what I needed out of it.
>
> Here is my attempt at using it:
>
> http://dump.thecybershadow.net/9562c8f705cb578be1e1513b6f931fb8/test.d
>
> However, calling b.foo2 prints AA.foo2 instead of B.foo2 due to 
> the bug I mentioned.

Since I do not have wrap to try it out(Kenji suggested using it 
in another post which is when I started looking at the typecons 
source) and as far as I can tell it actually wraps a type rather 
than just implements functions for an interface, it is not 
exactly what I needed, but code wise, pretty close. I didn't need 
to create a new wrapper class but just mixin the implementations 
of an interface(although, in theory, one could also use it for 
abstract methods).





More information about the Digitalmars-d mailing list