public member function (公共成员函数)
<random>
result_type operator()();
生成随机数
Returns a new random number. (返回一个新的随机数。)
The engine's transition algorithm picks a value in the internal table (which is returned by the function) and replaces it with a new value obtained from its base engine. (引擎的转换算法选择内部表中的一个值(由函数返回),并用从其基类引擎获得的新值替换它。)
The generation algorithm simply returns the value picked. (生成算法简单地返回所选的值。)
返回值
A new random number. (一个新的随机数。)
result_type (结果类型)is a member type, defined as an alias of the type of the numbers generated by the base engine. (是一种成员类型,定义为由基类引擎生成的数字类型的别名。)
示例
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
// shuffle_order_engine::operator()
#include <iostream>
#include <chrono>
#include <random>
int main ()
{
// obtain a seed from the system clock:
unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
// knuth_b is a standard shuffle_order_engine type:
std::knuth_b generator (seed);
std::cout << "Random value: " << generator() << std::endl;
return 0;
}
|
可能的输出
复杂度
Determined by the base engine. (由基类引擎决定。)