29 static std::default_random_engine e ;
31 static bool seeded = false ;
34 #if defined(G_WINDOWS)
35 std::random_device r ;
37 std::random_device r(
"/dev/urandom" ) ;
40 using seed_t = std::random_device::result_type ;
42 try { seed_1 = r() ; }
catch( std::exception & ) {}
44 auto tp = std::chrono::high_resolution_clock::now() ;
45 auto seed_2 =
static_cast<seed_t
>( tp.time_since_epoch().count() ) ;
47 std::seed_seq seq{ seed_1 , seed_2 } ;
52 std::uniform_int_distribution<unsigned int> dist( start , end ) ;
unsigned int rand(unsigned int start=0U, unsigned int end=32767)
Returns a random value, automatically seeded on first use.