Firstly, I have no problems, but I like to keep everything as simple as possible. I am using a template with a template named Math, and besides many other things, there are random functions.
Various types of random functions and a function for setting a random seed. Therefore, every function except the seed function uses a type class Real. But when I want to set the seed, I have to pass some random (ha ha) type in order to be able to call the function:
Math<u32>::SeedRandom(System::time());
Again this is not a real problem, but I am curious if it is possible to get the same result without using <u32>.
Here is a snippet from the Math class:
template <class Real>
class Math
{
public:
static void SeedRandom(u32 seed) { srand(seed); }
static Real UnitRandom() { return (Real)((f64)rand() / (f64)RAND_MAX); }
};
by the way. f64typedef'd before doubleand u32before unsigned int.