"pompei2" , dans le message (digitalmars.D.learn:31164), a écrit : > This is what I have, which works but has severe code duplication. > I hoped inout would help me here, but I just can't figure it out. > I also gave a try to ranges, but same thing again: I can only get > it to work if I define my things twice.
It's not optimal, and there is an ugly cast, but maybe this is a suitable workarrond for you : int delegate(int delegate(ref int)) doIter() const { return (int delegate(ref int) dg) { cast(typeof(this))(this).doIter()((ref int i) { int copy = i; dg(copy); }); } } Until int delegate(ref inout int) opApply() inout; and int delegate(int delegate(ref inout int)) doIter() inout; are made to work. (I actually don't know if there is any obstacles to do this).