Re: usage of ref foreach with variadic functions fails with "cannot be ref"

2017-02-12 Thread error via Digitalmars-d-learn
On Sunday, 12 February 2017 at 03:34:19 UTC, Michael Coulombe wrote: Do you have a complete code example that gives your error? I can't reproduce it (DMD v2.073.0): int foo(T...)(T vars) { int i = 0; foreach(ref v ; vars) { v = 5; i += v; } return i; } void bar

Re: usage of ref foreach with variadic functions fails with "cannot be ref"

2017-02-11 Thread Michael Coulombe via Digitalmars-d-learn
On Saturday, 11 February 2017 at 15:02:11 UTC, error wrote: On Saturday, 11 February 2017 at 14:43:18 UTC, rikki cattermole wrote: Try: foreach(i, v; vars) { vars[i] = ...; } Perfect! Thanks so much - I wish that hint was in the documentation for variadic functions, although I guess

Re: usage of ref foreach with variadic functions fails with "cannot be ref"

2017-02-11 Thread error via Digitalmars-d-learn
On Saturday, 11 February 2017 at 14:43:18 UTC, rikki cattermole wrote: Try: foreach(i, v; vars) { vars[i] = ...; } Perfect! Thanks so much - I wish that hint was in the documentation for variadic functions, although I guess it suggests an inefficiency in the compiler - since there wo

Re: usage of ref foreach with variadic functions fails with "cannot be ref"

2017-02-11 Thread rikki cattermole via Digitalmars-d-learn
On 12/02/2017 3:41 AM, error wrote: I'm making a serializer that has a variadic write method that takes arbitrary params and serializes them; I want to do the same thing with a read method ( pass in your params by ref, and it populates them with data ) - however, I run into a compiler error - "

usage of ref foreach with variadic functions fails with "cannot be ref"

2017-02-11 Thread error via Digitalmars-d-learn
I'm making a serializer that has a variadic write method that takes arbitrary params and serializes them; I want to do the same thing with a read method ( pass in your params by ref, and it populates them with data ) - however, I run into a compiler error - "cannot be ref" in the foreach state