discard_block::seed
Injecte l'état stocké.
void seed();
template<class Gen>
void seed(Gen& gen);
Paramètres
Gen
Le type du générateur de départ.gen
Le concepteur de départ.
Notes
Les premiers appels de fonction valeur de stored_eng.seed() et définit count à 0.Le deuxième appel de fonction valeur de stored_eng.seed(gen) et définit count à 0.
Exemple
// std_tr1__random__discard_block_seed.cpp
// compile with: /EHsc
#include <random>
#include <iostream>
typedef std::mt19937 Myeng;
typedef std::discard_block<Myeng, 2, 1> Myceng;
int main()
{
Myeng eng;
Myceng ceng;
const Myceng::base_type& base = ceng.base(); // get base engine
Myceng::result_type compval = ceng();
compval = compval; // to quiet "unused" warnings
base.min();
std::cout << "P == " << Myceng::block_size << std::endl;
std::cout << "R == " << Myceng::used_block << std::endl;
std::cout << "min == " << ceng.min() << std::endl;
std::cout << "max == " << ceng.max() << std::endl;
ceng.seed(); // reseed base engine
std::cout << "a random value == " << ceng() << std::endl;
std::cout << "a random value == " << ceng() << std::endl;
std::cout << "a random value == " << ceng() << std::endl;
Myceng ceng2(eng); // construct with generator
ceng2.seed(eng); // seed with generator
return (0);
}
Configuration requise
en-tête : <random>
l'espace de noms : DST