<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引擎決定。)

另見