
I would like to suggest an enhancement to the documentation for the random library. The documentation for the number generators advises not to construct generators frequently for various reasons. On some platforms there could also be an issue with memory use where the generators are created on the stack. I have used the suggested mt19937 generator that is about 5000 bytes in size on my system. If I create two of these on the stack then I get a crash. I followed the "very quick start" example that creates the generator on the stack and has a variate_generator like this: boost::mt19937 rng; boost::uniform_int<> six(1,6) boost::variate_generator<boost::mt19937, boost::uniform_int<> > die(rng, six); Thus, each instance of variate_generator has a copy of the generator too. The random_demo.cpp works just fine because it uses an alias for the generator: boost::variate_generator<base_generator_type&, boost::uniform_real<> > thus multiple copies of the variate_generator on the stack are fine. I guess what this comes down to is a warning about creating multiple instances on the stack of generators and/or variate_generators where the engine template parameter to variate_generator is a engine rather than a pointer or reference to an engine. Richard