Skip to content

Instantly share code, notes, and snippets.

@menyf
Created January 26, 2018 09:01
Show Gist options
  • Save menyf/3afb3be1a168282ee069f6263a37b128 to your computer and use it in GitHub Desktop.
Save menyf/3afb3be1a168282ee069f6263a37b128 to your computer and use it in GitHub Desktop.
random_double
#include <random>
class Random {
public:
Random(double low, double high) {
rd = new std::random_device;
gen = new std::mt19937((*rd)());
dis = new std::uniform_real_distribution<double>(low, high);
}
~Random() {
delete dis;
delete gen;
delete rd;
}
double next() const { return (*dis)(*gen); }
private:
std::random_device *rd;
std::mt19937 *gen;
std::uniform_real_distribution<double> *dis;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment