std::random_device
De cppreference.com
![]() |
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
Déclaré dans l'en-tête <random>
|
||
class random_device; |
(depuis C++11) | |
std::random_device
est uniformément distribuée un générateur de nombre aléatoire entier, qui produit non déterministes nombres aléatoires, si une source non-déterministe (par exemple, un dispositif matériel) est disponible pour la mise en oeuvre .Original:
std::random_device
is a uniformly-distributed integer random number generator, which produces non-deterministic random numbers, if a non-deterministic source (e.g. a hardware device) is available to the implementation.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[modifier] Types de membres
Type du membre | Définition |
result_type
|
unsigned int |
[modifier] Fonctions membres
Original: Construction The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. | |
construit le moteur Original: constructs the engine The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (fonction membre publique) | |
operator= ( supprimée )Original: deleted The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
l'opérateur d'affectation est supprimé Original: the assignment operator is deleted The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (fonction membre publique) |
Original: Generation The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. | |
avancées état du moteur et retourne la valeur générée Original: advances the engine's state and returns the generated value The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (fonction membre publique) | |
Original: Characteristics The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. | |
obtient l'estimation de l'entropie pour le générateur de non-déterministe de nombres aléatoires Original: obtains the entropy estimate for the non-deterministic random number generator The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (fonction membre publique) | |
[ statique ]Original: static The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
obtient la valeur la plus petite possible dans la plage de sortie Original: gets the smallest possible value in the output range The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (fonction membre publique statique) |
[ statique ]Original: static The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
obtient la plus grande valeur possible dans la plage de sortie Original: gets the largest possible value in the output range The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (fonction membre publique statique) |
[modifier] Exemple
#include <iostream> #include <string> #include <map> #include <random> int main() { std::random_device rd; std::map<int, int> hist; for(int n=0; n<20000; ++n) ++hist[rd()%10]; for(auto p : hist) std::cout << p.first << " : " << std::string(p.second/100, '*') << '\n'; }
Résultat :
0 : ******************** 1 : ******************* 2 : ******************** 3 : ******************** 4 : ******************** 5 : ******************* 6 : ******************** 7 : ******************** 8 : ******************* 9 : ********************