C++ Standard RNG
We provide a C++ client which satisies the concepts of the standard C++ random number engine.
Get the code
The client code is available as part of the OpenQu project. The latest version can also be downloaded from here:
Dependencies
The code only depends on the C++11 standard library and libCURL. In order to compile only the following flags should be needed
c++ -std=c++11 -lcurl main.cpp
In case the libCURL is not found, you should specify the include and library directories with -I/path/to/libcurl/include
and -I/path/to/libcurl/lib
, respectively.
Example
Print some random numbers
#include <iostream>
#include "remote_engine.hpp"
int main() {
openqu::random::remote_engine rng("http://random.openqu.org/api");
std::cout << "Random number: " << rng() << std::endl;
}
Use with standard distribution
#include <iostream>
#include <random>
#include "remote_engine.hpp"
int main() {
openqu::random::remote_engine engine("http://random.openqu.org/api");
std::binomial_distribution<> d(4, 0.5);
std::cout << "Random number: " << d(engine) << std::endl;
}