Currently i’m using boost for random, but there is a possibility i will switch it to other library or my own code(in some parts), so i want to wrap it inside a class and then when i need some random number (or something else) i will get it from this class instead of boost itself. The question is – how should i do it? Should i make this class a singleton or a static class or something else?
(I thought of a class because i need to seed only once but get functionality from different places and i dont want to seed in main.cpp)
P.S. If there is a way of doing it without a class, it will do as well.
I would recommend making a regular class. This way the user can create an object, set some parameters and then query the values as in this example use case:
This approach will make it possible to create different random generators for different distributions. Either through different classes (YourUniformRandomGenerator, YourGaussDistributedRandomGenerator, …) or through parametrization methods (SetUniform, SetGauss, …). If you want to seed only once (why would you want to do that?), all those generator classes could access the same static boost random generator.