<random>

public member function (公共成员函数)
<random>

std::independent_bits_engine::operator()

result_type operator()();
生成随机数
Returns a new random number. (返回一个新的随机数。)

The engine's transition algorithm invokes the base engines's (引擎的转移算法调用了base引擎的)operator()member as many times as needed to obtain enough significant bits to construct a random value. (成员,根据需要多次调用,以获得足够的有效位来构造一个随机值。)

The generation algorithm joins the bits obtained above to generate a single value, which is returned by this member function. (生成算法将上面获得的位连接起来以生成单个值,该值由该成员函数返回。)

参数



返回值

A new random number. (一个新的随机数。)
result_type (结果类型)是一种成员类型,定义为由 base 引擎生成的数字类型的别名。

示例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// independent_bits_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();

  std::independent_bits_engine<std::mt19937,64,std::uint_fast64_t> generator (seed);
  std::cout << "Random value: " << generator() << std::endl;

  return 0;
}

可能的输出
Random value: 7627186886521130655


复杂度

Determined by the base engine. (由base引擎决定。)

另见