Should I use a random engine seeded from std::random_device or use std::random_device every time

后端 未结 6 1763
梦如初夏
梦如初夏 2020-12-30 00:16

I have a class that contains two sources of randomness.

std::random_device rd;
std::mt19937 random_engine;

I seed the std::mt19937

6条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-30 00:28

    You may want to have a look at http://channel9.msdn.com/Events/GoingNative/2013/rand-Considered-Harmful that explains why you should use uniform_int_distribution, and the relatives strengths of random_device / mt19937.

    In this video, Stephan T. Lavavej specifically states that on visual C++, random_device can be used for cryptographic purposes.

提交回复
热议问题