public member function (公共成员函数)
<random>
result_type operator()();
生成随机数
Returns a new random number. (返回一个新的随机数。)
The function advances the internal state by calling its transition algorithm which applies a subtract-with-carry operation on the state sequence element. (该函数通过调用其 *转换算法* 来推进内部状态,该算法对状态序列元素应用减法进位运算。)
Its generation algorithm is a direct copy of the value generated with the transition algorithm. (它的 *生成算法* 是使用 *转换算法* 生成的值的直接副本。)
返回值
A new random number. (一个新的随机数。)
result_type (结果类型)是一个成员类型,定义为第一个类模板参数的别名 (UIntType).
示例
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
// subtract_with_carry::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();
std::subtract_with_carry_engine<unsigned,24,10,24> generator (seed);
std::cout << "Random value: " << generator() << std::endl;
return 0;
}
|
可能的输出
复杂度
Amortized constant. (分摊常数。)