エンジンを構築します。
subtract_with_carry_01();
explicit subtract_with_carry_01(unsigned long x0);
template<class Gen>
subtract_with_carry_01(Gen& gen);
subtract_with_carry_01(const subtract_with_carry_01& right);
subtract_with_carry_01(subtract_with_carry_01& right);
パラメーター
x0
シード値。Gen
シード ジェネレーターの型。gen
シード ジェネレーター。right
subtract_with_carry_01 オブジェクト。
解説
1 つ目のコンストラクターは、subtract_with_carry_01 オブジェクトを構築し、seed() を呼び出して初期化します。
2 つ目のコンストラクターは、subtract_with_carry_01 オブジェクトを構築し、seed(x0) を呼び出して初期化します。
3 つ目のコンストラクターは、subtract_with_carry_01 オブジェクトを構築し、seed(first, last) を呼び出して初期化します。
4 つ目と 5 つ目のコンストラクターは、subtract_with_carry_01 オブジェクトをコピーして subtract_with_carry_01 オブジェクトを構築します。
使用例
// std_tr1__random__subtract_with_carry_01_construct.cpp
// compile with: /EHsc
#include <random>
#include <iostream>
typedef std::mt19937 Myeng;
typedef std::subtract_with_carry_01<float, 24, 10, 24> Myceng;
int main()
{
Myeng eng;
Myceng ceng;
Myceng::result_type compval = ceng();
compval = compval; // to quiet "unused" warnings
std::cout << "W == " << Myceng::word_size << std::endl;
std::cout << "S == " << Myceng::short_lag << std::endl;
std::cout << "R == " << Myceng::long_lag << 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
Myceng ceng3(5UL); // construct with unsigned long seed
ceng3.seed(5UL); // seed with unsigned long
return (0);
}
必要条件
ヘッダー : <random>
名前空間: std