seeding default_random_engine?

后端 未结 2 1288
野性不改
野性不改 2021-01-02 16:15

I\'m using visual studio 2010 which doesn\'t support , so I have to seed default_random_engine. Thus, I\'ve decided to seed it with <

2条回答
  •  滥情空心
    2021-01-02 16:42

    According to http://www.cplusplus.com/reference/random/random_device/, they recommend that you don't use std::random_device, as it isn't portable:

    Notice that random devices may not always be available to produce random numbers (and in some systems, they may even never be available).

    On a related page (http://www.cplusplus.com/reference/random/linear_congruential_engine/linear_congruential_engine/), they give the following as an example of creating a seed:

    unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
    

提交回复
热议问题