https://issues.dlang.org/show_bug.cgi?id=7067
Martin Nowak <c...@dawg.eu> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |c...@dawg.eu --- Comment #19 from Martin Nowak <c...@dawg.eu> --- We had a talk about this during the 2nd D meetup in Berlin. One remaining question was how to deal with memory management when using a reference type RNG. I came up with a different solution and less invasive solution. We simply disable implicit copying of RNGs (@disable this(this)) and ask people to use explicitly use .save when copying is indeed intended. We can even deprecate postblit like so. deprecated("Please use .save to explicitly copy RNGs.") this(this) {} Internally we'd need to change all copying to use std.algorithm.move. If reference semantic is wanted people can use either new Random(unpredictableSeed) or refCounted(rnd) refCounted(Random(unpredictableSeed)) or (unsafe) refRange(&rnd) . This should also work for combined random generators like. new Exponential(Random(unpredictableSeed)) refCounted(Exponential(Random(unpredictableSeed))) auto rng = Exponential(Random(unpredictableSeed)); refRange(&rng); --