There are a few ideas that come to mind for porting this code to pre-C++11:
Use boost.
Boost random_device
and boost::mt19937
should work just as well as the C++11 standard versions. Boost also has its own uniform_real_distribution
, which was the prototype for the standard stuff.
Bring the implementations in tree.
The paper that introduced mersenne twister random number generators included a reference implementation of the generator.
http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/ARTICLES/mt.pdf
If you are mainly interested in network testing, you probably don't care about being cross-platform (specifically, working on windows.) The libc++ implementation of std::random_device
is only about a dozen lines of code, all it does is open /dev/random
as a file, and reinterpret_cast
reads from that file as uint32_t
and return them.
You could look at the msvc version of std::random_device
and incorporate that also if you want to work on windows... iirc there is no mingw implementation of that right now, and the windows one uses some crypto API.
- Use some other open source rng library. You could look at trng.