Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Constructs the distribution.
explicit uniform_real(result_type min0 = result_type(0), result_type max0 = result_type(1));
Parameters
min0
The lower bound for random values.max0
The upper bound for random values.
Remarks
Precondition: min0 < max0
The constructor constructs an object whose stored value stored_min holds the value min0 and whose stored value stored_max holds the value max0.
Example
// std_tr1__random__uniform_real_construct.cpp
// compile with: /EHsc
#include <random>
#include <iostream>
typedef std::ranlux64_base_01 Myeng;
typedef std::uniform_real<double> Myceng;
int main()
{
Myeng eng;
Myceng ceng(1.0, 2.0);
Myceng::input_type engval = eng();
Myceng::result_type compval = ceng(eng);
compval = compval; // to quiet "unused" warnings
engval = engval;
std::cout << "min == " << ceng.min() << std::endl;
std::cout << "max == " << ceng.max() << std::endl;
ceng.reset(); // discard any cached values
std::cout << "a random value == " << ceng(eng) << std::endl;
std::cout << "a random value == " << ceng(eng) << std::endl;
std::cout << "a random value == " << ceng(eng) << std::endl;
return (0);
}
min == 1 max == 2 a random value == 1.28517 a random value == 1.2238 a random value == 1.23248
Requirements
Header: <random>
Namespace: std