vendredi 11 novembre 2016

Create custom distribution compatible with C++11 random header

Is it possible to create a custom distribution besides the ones in the <random> library? I'd like to make a distribution that behaves (in interface) like

std::uniform_int_distribution
std::normal_distribution
...etc

By that I mean I'd like to do something like the following

std::random_device rd;
std::mt19937 gen(rd());

// Is something like the following possible?
my_custom_distribution dist;
dist(gen);

It looks like the distributions must follow the RandomNumberDistribution concept. Is it possible to create a new type of distribution that "plays nicely" with the other utilities, namely the generators and engines?




Aucun commentaire:

Enregistrer un commentaire