Export (0) Print
Expand All

random_device::operator()

Returns a random value.

result_type operator()();

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

 

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

Header: <random>

Namespace: std::tr1

Community Additions

ADD
Show:
© 2014 Microsoft