variate_generator::variate_generator
Constrói o gerador.
variate_generator(engine_type eng0, distribution_type dist0);
Parâmetros
eng0
O objeto do mecanismo a quebra automática.dist0
O objeto de distribuição a quebra automática.
Comentários
O construtor constrói um objeto cujo valor armazenado eng manter eng0 e cujo valor armazenado dist manter dist0.
Exemplo
// std_tr1__random__variate_generator_construct.cpp
// compile with: /EHsc
#include <random>
#include <iostream>
typedef std::minstd_rand Myeng;
typedef std::uniform_int<unsigned int> Mydist;
typedef std::variate_generator<Myeng, Mydist> Myceng;
int main()
{
Myeng eng0;
Mydist dist0;
Myceng ceng(eng0, dist0);
const Myceng::engine_type& eng = ceng.engine(); // get base engine
const Myceng::distribution_type& dist =
ceng.distribution(); // get distribution
Myceng::result_type compval = ceng();
compval = compval; // to quiet "unused" warnings
eng.min();
dist.min();
std::cout << "min == " << ceng.min() << std::endl;
std::cout << "max == " << ceng.max() << std::endl;
std::cout << "a random value == " << ceng() << std::endl;
std::cout << "a random value == " << ceng() << std::endl;
std::cout << "a random value == " << ceng() << std::endl;
return (0);
}
Requisitos
Cabeçalho: <random>
namespace: STD