且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

C ++线程安全的均匀分布随机数生成

更新时间:2023-02-10 13:34:26

基于已经

Based on the already mentioned solution, here is a version adapted to your specific needs:

double doubleRand(double min, double max) {
    thread_local std::mt19937 generator(std::random_device{}());
    std::uniform_real_distribution<double> distribution(min, max);
    return distribution(generator);
}