[Issue 7543] inout opApply should work properly

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Mar 9 16:36:15 PST 2012


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



--- Comment #13 from timon.gehr at gmx.ch 2012-03-09 16:36:19 PST ---
(In reply to comment #12)
> 
> I didn't know at first that you wanted to point this out (probably was too
> distracted by your code example).
> 

It seems to me in general that it could be beneficial to the quality of your
contributions if you would spend more time reading and less time writing. ;)

> 
> So, with inout_t you would write:
> class C {
>     int[] arr;
>     this(int[] a){arr = a;}
>     int opApply(int delegate(ref inout_t(int)) dg) inout {
>         foreach(ref e; arr)
>             if(auto r = dg(e)) return r;
>         return 0;
>     }
> }
> 

This is an interesting suggestion. There are some other ideas discussed here:
http://forum.dlang.org/post/jhr0t6$24v6$1@digitalmars.com

> BTW: If D didn't have transitive const, you could implement it with inout_t
> like this:
> struct S{inout_t(S)* next;}

This is moot.

-- 
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