subtract_with_carry::operator()
傳回選擇性值。
result_type operator()();
備註
成員函式藉由套用遞迴關聯性會在虛擬隨機序列中的下一個值所儲存的記錄值,將自動產生的值,並將它傳回。
範例
// std_tr1__random__subtract_with_carry_operator_fn.cpp
// compile with: /EHsc
#include <random>
#include <iostream>
typedef std::mt19937 Myeng;
typedef std::subtract_with_carry<unsigned int, 1 << 24,
10, 24> Myceng;
int main()
{
Myeng eng;
Myceng ceng;
Myceng::result_type compval = ceng();
compval = compval; // to quiet "unused" warnings
std::cout << "M == " << Myceng::modulus << 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