Is there any reason to use non-ref foreach?

Dukc ajieskola at gmail.com
Fri Aug 31 17:49:31 UTC 2018


On Friday, 31 August 2018 at 12:52:17 UTC, bauss wrote:
> In reality you're micro-optimizing something that doesn't 
> require it.

I think you misunderstood. I wasn't trying to optimize, I was 
looking for a general way to iterate.

> I can't see the benefit other than added complexity.

I just explained it. Iterating by ref works with elements that 
have postblits disabled, iterating by value doesn't.

I was wondering that if iterating by ref is the most general way 
to iterate, why it isn't the default? Is there some big 
implication in using it?


More information about the Digitalmars-d-learn mailing list