random_device::operator()

Returns a random value.

result_type operator()();

Remarks

The member function returns values uniformly distributed in the closed interval [min(), max()].

Example

 

// std_tr1__random__random_device_operator_fn.cpp 
// compile with: /EHsc 
#include <random> 
#include <iostream> 
 
typedef std::tr1::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::tr1

See Also

Reference

<random>

random_device Class