Using inout in delegate

Jacob Carlborg doob at me.com
Thu Mar 28 08:31:33 PDT 2013


On 2013-03-28 15:16, Steven Schveighoffer wrote:

> Like Timon said, it's a bug in inout design.
>
> I'm not sure what __aggr1174 is, but you can fix the e error by
> specifying the type for e (or specifying it as const).
>
> I'm assuming the issue is that the compiler is trying to generate a
> struct to hold the stack data for foo, and struct members cannot be inout.
>
> It is a difficult problem to solve, because inout has two meanings
> depending on whether it is a parameter/return or a local variable.  At
> some point, we need to address this, because inout has so much
> potential, but suffers from some large deficiencies.

I had to change to a regular for-loop and declare the element as "const":

for (size_t i = 0; i < arr.length; i++)
{
     const e = arr[e];
}

-- 
/Jacob Carlborg


More information about the Digitalmars-d-learn mailing list