Christophe Travert, dans le message (digitalmars.D:173787), a écrit :
> "bearophile" , dans le message (digitalmars.D:173647), a écrit :
>> Turning that in D code that uses opApply is not hard, but the
>> code inflates 3X, and you can't use most std.algorithm on it.
>
> I believe most std.algorithm that work on input range could be made to
> work with opApply, or opApply-like delegates. It just wouldn't be
> particularly efficient unless agressive inlining is used.
>
> For example, filter could work like this for opApply-like delegates:
>
> template filter(pred)
> {
> auto filter(T)(int delegate(int delegate(ref T)) apply)
> {
> return (int delegate(ref T) dg)
> {
> return apply( (ref T t) { return pred(t)? dg(t): 1; });
^should read 0
> }
> }
> }
>
> --
> Christophe