random_device::operator()
乱数値を返します。
result_type operator()();
解説
このメンバー関数は、[min(), max()] の閉区間で一様に分布した値を返します。
使用例
// std_tr1__random__random_device_operator_fn.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