#include #include #include using namespace std; int main(int argc, char **argv) { uniform_int_distribution uniform05(0,5); mt19937 mtengine; // mt199937 is a version of mersenne_twister_engine // others like knuth_b, example of shuffle_order_engine // use mtengine.seed() to set the seed // initial seed specified as last template argument (mt19937 // has an initial seed of 1812433253, for example) // (SeqT is a type that is set by the template arguments as well --- // my199937 has it as uint_fast_32_t) // There is a default_random_engine type defined, but it is // implementation defined // There is also a random_device class (a generator) defined that // uses a non-deterministic random source (like hardware), if it // is available for(int i=0;i<40;i++) cout << uniform05(mtengine) << ' '; cout << endl; auto unisampler05 = bind(uniform05,mtengine); for(int i=0;i<40;++i) cout << unisampler05() << ' ' ; cout << endl; // other generators: uniform_real_distribution // geometric_distribution // normal_distribution // look at seed_seq to generate a *sequence* of seed values }