Espacios de nombres
Variantes

std::random_device::random_device

De cppreference.com
 
 
 
Generación de números pseudoaleatorios
Motores y adaptadores de motor
Original:
Engines and engine adaptors
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Generadores
Original:
Generators
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Distribuciones
Original:
Distributions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Distribuciones uniformes
Original:
Uniform distributions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Bernoulli distribuciones
Original:
Bernoulli distributions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Poisson distribuciones
Original:
Poisson distributions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Distribuciones normales
Original:
Normal distributions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Distribuciones de muestreo
Original:
Sampling distributions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Secuencias de semillas
Original:
Seed Sequences
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
(C++11)
C biblioteca
Original:
C library
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
 
std::random_device
Las funciones miembro
Original:
Member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Generación
Original:
Generation
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Características
Original:
Characteristics
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
 
<tbody> </tbody>
explicit random_device(const std::string& token = /*implementation-defined*/ );
(desde C++11)
Construye un objeto std::random_device nuevo, haciendo uso de la token argumento, si se proporciona, en aplicación definida por el modo .
Original:
Constructs a new std::random_device object, making use of the argument token, if provided, in implementation-defined manner.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Implementación típica en un sistema Linux, por ejemplo, espera token a ser el nombre de un dispositivo de caracteres que produce números aleatorios cuando se leen de, con el valor por defecto "/dev/urandom" .
Original:
Typical implementation on a Linux system, for example, expects token to be the name of a character device that produces random numbers when read from, with the default value "/dev/urandom".
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Excepciones

Lanza una excepción definidos implementación derivados de std::exception en caso de fallo .
Original:
Throws an implementation-defined exceptions derived from std::exception on failure.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Ejemplo

Demuestra los dos tipos comúnmente disponibles de std::random_device en Linux
Original:
Demonstrates the two commonly available types of std::random_device on Linux
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

#include <iostream>
#include <random>

int main()
{

    std::uniform_int_distribution<int> d(0, 10);

    std::random_device rd1; // uses /dev/urandom
    for(int n = 0; n < 10; ++n)
        std::cout << d(rd1) << ' ';
    std::cout << '\n';

    std::random_device rd2("/dev/random"); // much slower on Linux
    for(int n = 0; n < 10; ++n)
        std::cout << d(rd2) << ' ';
    std::cout << '\n';
}

Salida:

7 10 7 0 4 4 6 9 4 7 
2 4 10 6 3 2 0 6 3 7