c++ - What other values will generate error when given to std::minstd_rand::seed()? -
i'm on vc++11, far values generate errors, not on ideone.com
#include "stdafx.h" #include <iostream> #include <random> using namespace std; int _tmain(int argc, _tchar* argv[]) //int main(int argc, char* argv[]) { //print_seq(seeded_rand(0x7fffffff,10)); //cout << print_seq(seeded_rand(0xffffffff,10)); ////print_seq(seeded_rand(0,10)); //cout << print_seq(seeded_rand(-50000,10)); //cout << print_seq(seeded_rand(1,10)); minstd_rand r1; minstd_rand0 r2; r1.seed(0); system("pause"); return 0; } those values generated errors
0xfffffffe 0x7fffffff -2 0 what other values supposed generate abort() call ?

visual c++ 11.0.61030.0 update 4
26.5.3.1/5
explicit linear_congruential_engine(result_type s = default_seed);effects: constructslinear_congruential_engineobject. ifc mod m0 ,s mod m0, sets engine’s state 1, otherwise sets engine’s states mod m.
for reason, msvc implementation chooses assert in debug build when "sets engine’s state 1" condition triggers; in release build, quietly seeds 1 instead of 0.
minstd_rand typedef linear_congruential_engine<uint_fast32_t, 48271, 0, 2147483647>. seed 0 modulo 2147483647 == 0x7fffffff meaningless (the generator produce sequence of zeros, if weren't adjusting seed 1 in case).
Comments
Post a Comment