C++11's new Random or Boost.Random is really cool, powerful and flexible but cumbersome to use because of choice of generator, distribution, seeding of state handling (and in turn re-entrency and thread-safety), etc.
Often, however, when creating mockup objects in unit tests we really just want a simple way of creating a random object of a specific type and don't care that must about specific parameters. I personally think C++ STL and Boost lacks an easy and reusable way of accomplishing this. We would really just want to say, for instance,
std::vector<uint32_t> x(10);
some_nice_namespace::randomize(x);
using some global state and only if needed be more specific like
some_nice_namespace::randomize(x, rng_state);
or even more specific like
some_nice_namespace::randomize(x, rng(rng_state));
Anybody that have worked both in for example Matlab and C/C++ should be very aware of this gap in productivity. Does any C++ library implement any of these ideas? If not I will implement them myself and perhaps add them to Boost.
Boost.Random doesn't seem to provide a class that binds a generator together with a distribution. You can make a template functor class that binds the two together.
Boost.Foreach and Boost.Range are useful for writing generic code that operates on any container, array, or pair of iterators.
I've come up with the following which allows you to randomize a container concisely, once you've defined a functor that binds a generator and a distribution.
By using template specialization, you can provide default generators for various numeric types: