Prettier iterator implementations in D?

David Medlock noone at nowhere.com
Fri Oct 20 07:03:30 PDT 2006


Bill Baxter wrote:
> Forgetting about 'foreach' for the moment, I'd like to talk about the 
> other end of things: opApply().
> <snip>

You could always use this handy template which automatically exposes any 
array or assoc-array in a class you want, with a single mixin.



class Foo
{
   Bar[]  bar;

   mixin applyThis!(Bar,array);
}


Bar b = new Bar();
foreach( Bar b; foo ) {...}

-DavidM
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: mixins.d
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20061020/05d9c4ec/attachment.ksh>


More information about the Digitalmars-d mailing list