so in my custom C++ library i wanted to create 2 reliable and simple functions, i for quickly generating a random number, and the other for doing the same thing but within a specified range, i came up with the following but would like to know if they are good:
int random()
{
std::random_device rd;
std::uniform_int_distribution<int>dist;
return dist(rd);
}
int randomWithinRange(int range)
{
std::random_device rd;
std::uniform_int_distribution<int>dist;
return (dist(rd) % range);
}
the functions work and compile alright, i just want to know how good they would be for long term inclusion
Aucun commentaire:
Enregistrer un commentaire