除<random>
库中的自定义分发外,是否可以创建自定义分发?我想做一个像
std::uniform_int_distribution
std::normal_distribution
...etc
我的意思是我想做类似以下的事情
std::random_device rd;
std::mt19937 gen(rd());
// Is something like the following possible?
my_custom_distribution dist;
dist(gen);
看起来分发必须遵循RandomNumberDistribution概念。是否有可能创建一种与其他公用事业“发挥良好”的新型发行方式,即发电机和发动机?
答案 0 :(得分:3)
最低要求是:
using result_type = ?;
result_type operator()();
static result_type min();
static result_type max();
其中result_type
是一些无符号整数类型。这是&#34; UniformRandomBitGenerator&#34;概念
大多数C ++ <random>
发行版也满足&#34; RandomNumberEngine&#34;。
有关详细信息,请参阅cppreference或标准。