QRandomGenerator64 类

QRandomGenerator64 类允许从高品质、无种子随机数生成器获取一 64 位随机值。 更多...

头: #include <QRandomGenerator64>
CMake: find_package(Qt6 COMPONENTS Core REQUIRED)
target_link_libraries(mytarget PRIVATE Qt6::Core)
qmake: QT += core
Since: Qt 5.10
继承: QRandomGenerator

公共类型

  result_type

公共函数

quint64 generate ()
QRandomGenerator64::result_type operator() ()

详细描述

QRandomGenerator64 is a simple adaptor class around QRandomGenerator , making the QRandomGenerator::generate64 () function the default for operator ()(), instead of the function that returns 32-bit quantities. This class is intended to be used in conjunction with Standard Library algorithms that need 64-bit quantities instead of 32-bit ones.

In all other aspects, the class is the same. Please refer to QRandomGenerator 文档编制了解更多信息。

另请参阅 QRandomGenerator .

成员类型文档编制

QRandomGenerator64:: result_type

A typedef to the type that operator () returns. That is, quint64.

另请参阅 operator ().

成员函数文档编制

quint64 QRandomGenerator64:: generate ()

Generates one 64-bit random value and returns it.

Note about casting to a signed integer: all bits returned by this function are random, so there's a 50% chance that the most significant bit will be set. If you wish to cast the returned value to qint64 and keep it positive, you should mask the sign bit off:

    qint64 value = QRandomGenerator64::global()->generate() & std::numeric_limits<qint64>::max();
					

另请参阅 QRandomGenerator and QRandomGenerator::generate64 ().

QRandomGenerator64::result_type QRandomGenerator64:: operator() ()

Generates a 64-bit random quantity and returns it.

另请参阅 QRandomGenerator::generate () 和 QRandomGenerator::generate64 ().