Re: How to modify an element in a range/collection using its member function?

2012-05-04 Thread Jens Mueller
Chris Cain wrote: On Thursday, 3 May 2012 at 10:03:55 UTC, Jens Mueller wrote: What is a good solution when using member functions on a range's/container's element? Note, the problem only applies when storing structs because classes behave like references. I think in this case, it might

How to modify an element in a range/collection using its member function?

2012-05-03 Thread Jens Mueller
Hi, in Phobos opIndex returns a copy due to the reasons outlined in TDPL p. 378 (hiding the storage). Even though I find the argumentation convincing and opIndexAssign/opIndexOpAssign usually makes the design sound I ran into surprises when using member functions. I use the Zip the range which

Re: How to modify an element in a range/collection using its member function?

2012-05-03 Thread Peter Alexander
I don't think that opIndexAssign/opIndexOpAssign were ever a good idea. Yeah, it works fine when all you are doing is x[i] = y, but that doesn't scale, as you have found out. It's short-sighted. x[i] is an L-value for arrays, so it should be for everything else where it makes sense.

Re: How to modify an element in a range/collection using its member function?

2012-05-03 Thread Chris Cain
On Thursday, 3 May 2012 at 10:03:55 UTC, Jens Mueller wrote: What is a good solution when using member functions on a range's/container's element? Note, the problem only applies when storing structs because classes behave like references. I think in this case, it might make sense to store