Prettier iterator implementations in D?
Bill Baxter
wbaxter at gmail.com
Fri Oct 20 10:19:13 PDT 2006
Reiner Pope wrote:
> The proposal looks good (as long as it creates no syntactical
> ambiguities) but if we had variadic template parameters (see
> http://www.generic-programming.org/~dgregor/cpp/variadic-templates.html
> for a good version for C++) then you could do it much more easily with
> templates:
>
> template IterFunc(type ...)
> {
> alias int delegate(type ...) IterFunc;
> }
Ooh, I missed this "Implicit Template Properties" thing. That's an
improvement over what I had even without the variadic bit. Just means I
need an IterFunc1, IterFunc2,... etc.
>
> and then you could just declare your iterators:
>
> int opApply(IterFunc!(int) dg)
> [...]
> Unfortunately, this wouldn't handle 'inout' parameters, since you can't
> instantiate a template with an inout parameter...
Ah, that's a pity. Is that a spec limitation or just something still on
the "todo" list?
--bb
More information about the Digitalmars-d
mailing list