On Tue, Jun 18, 2013 at 04:50:07PM +0200, monarch_dodra wrote: > On Tuesday, 18 June 2013 at 14:18:19 UTC, H. S. Teoh wrote: > >[...] > > > >Just make RNGs passed by reference, and the above problem will not > >happen. > > > > > >T > > Well... it's more than *just* pass-by-reference, its actual > store-by-reference (eg "reference semantic").
Good point. > In the case of "take", take store a copy of the passed range, so a > pass-by-reference wouldn't really change much. If the RNG were a reference type like a class, then the wrapper range Take would simply have another reference to the class instance, so the problem is avoided. But if it were only passed by reference but is a value type (e.g. modify take() to have a ref argument), then the problem will still persist, since the wrapper ctor will copy the RNG instance. > I'm not sure if that's what you meant, but just in case. We don't > want any ambiguity on the words we are using. Thanks! T -- Государство делает вид, что платит нам зарплату, а мы делаем вид, что работаем.