Using inout in delegates

Jacob Carlborg doob at me.com
Mon Oct 8 23:33:06 PDT 2012


On 2012-10-08 21:40, Timon Gehr wrote:

> The original behaviour is to be expected and the workaround exploits a
> compiler bug.
>
> The correct way to get rid of the compile error is:
>
> void foo(inout(int)[] arr){
>      auto a = { const b = arr[0]; } // or int b = arr[0];
> }

Why can't "auto" work there? BTW, this doesn't work:

void foo (inout(int)[] arr)
{
     auto a = {
         foreach (int e ; arr) {}
     };
}

-- 
/Jacob Carlborg


More information about the Digitalmars-d-learn mailing list