random_device::random_device

构造引擎。

random_device(const std::string& str);

参数

  • str
    初始化字符串。

备注

构造函数初始化计算机(根据需要)具有 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); 
    } 
 
  

要求

标头: <random>

命名空间: std

请参见

参考

<random>

random_device Class