random_device::random_device

Constructs the engine.

random_device(const std::string& str);

Parameters

  • str
    The initialization string.

Remarks

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

Example

 

// 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

Requirements

Header: <random>

Namespace: std

See Also

Reference

<random>

random_device Class

Other Resources

<random> Members