This documentation is archived and is not being maintained.

random_device::random_device

Constructs the engine.

random_device(const std::string& str);

str

The initialization string.

The constructor initializes the device (as needed) with str.

 

// std_tr1__random__random_device_construct.cpp 
// compile with: /EHsc 
#include <random> 
#include <iostream> 
 
typedef std::random_device Myceng; 
int main() 
    { 
    Myceng ceng; 
    Myceng::result_type compval = ceng(); 
 
    compval = compval;  // to quiet "unused" warnings 
 
    std::cout << "entropy == " << ceng.entropy() << std::endl; 
    std::cout << "min == " << ceng.min() << std::endl; 
    std::cout << "max == " << ceng.max() << std::endl; 
 
    std::cout << "a random value == " << ceng() << std::endl; 
    std::cout << "a random value == " << ceng() << std::endl; 
    std::cout << "a random value == " << ceng() << std::endl; 
 
    return (0); 
    } 
 
entropy == 0
min == 0
max == 4294967295
a random value == 2439379569
a random value == 2439379569
a random value == 2439379569

Header: <random>

Namespace: std

Show: