Using inout in delegate
Jacob Carlborg
doob at me.com
Thu Mar 28 01:34:36 PDT 2013
The following code fails to compile:
void foo (inout int[] arr)
{
auto dg = {
foreach (i, e ; arr) {}
};
dg();
}
void main ()
{
auto a = [3, 4, 5];
foo(a);
}
Error message:
main.d(9): Error: variable main.foo.__lambda1.__aggr1174 inout variables
can only be declared inside inout functions
main.d(9): Error: variable main.foo.__lambda1.e inout variables can only
be declared inside inout functions
If I remove the delegate everything compiles. Am I doing something wrong?
--
/Jacob Carlborg
More information about the Digitalmars-d-learn
mailing list