discard_block::discard_block
Constructs the engine.
discard_block();
explicit discard_block(const base_type& eng);
explicit discard_block(result_type seed);
template<class Gen>
discard_block(Gen& gen);
discard_block(const discard_block& right);
discard_block(discard_block& right);
Parameters
eng
An engine object.seed
A seed value.Gen
The type of the seed generator.gen
The seed generator.right
A discard_block Class object.
Remarks
The first constructor constructs a discard_block object with a default-initialized engine. The second constructor constructs a discard_block object with a copy of an engine object. The third constructor constructs a discard_block object with an initial seed value.The fourth constructor constructs a discard_block object with an engine initialized from a generator. The fifth and sixth constructors construct a discard_block object by copying a discard_block object.
Example
// std_tr1__random__discard_block_discard_block.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);
}
P == 2 R == 1 min == 0 max == 4294967295 a random value == 3499211612 a random value == 3890346734 a random value == 545404204
Requirements
Header: <random>
Namespace: std