called copy constructor in foreach with ref on Range

Paul Backus snarwin at gmail.com
Mon Jun 22 21:38:02 UTC 2020


On Monday, 22 June 2020 at 21:33:08 UTC, H. S. Teoh wrote:
>
> Jonathan is coming from the POV of generic code.  The problem 
> with move leaving the original range in its .init state isn't 
> so much that it will crash or anything (even though as you said 
> that does indicate a flaw in the range's implementation), but 
> that the semantics of generic code changes in subtle ways. For 
> example:
>
> [...]

Seems to me like adding some unit tests with non-copyable input 
ranges to Phobos could expose a number of latent bugs.


More information about the Digitalmars-d-learn mailing list