Vary range of uniform_int_distribution

前端 未结 3 1135
故里飘歌
故里飘歌 2020-12-01 05:20

So i have a Random object:

typedef unsigned int uint32;

class Random {
public:
    Random() = default;
    Random(std::mt19937::result_type seed) : eng(seed         


        
3条回答
  •  爱一瞬间的悲伤
    2020-12-01 06:10

    You can simply create a std::uniform_int_distribution::param_type and modify the range using the param() method. You can cut down the template noise with decltype :

    decltype(uniform_dist.param()) new_range (0, upper);
    uniform_dist.param(new_range);
    

提交回复
热议问题