To use uniform_random_value()
include/paste the header random_value.hpp
from this gist in your project; you can after simply write :
int randomInt = uniform_random_value(1, 100);
float randomFloat = uniform_random_value(1.0f, 100.0f);
double randomDouble = uniform_random_value(1.0, 100.0);
For the instance where you want a random boolean you can write :
bool randomBool = uniform_random_value<bool>();
When you have diferrent input types (assuming they are implicitly convertible) choose the right one with the syntax :
auto randomValue = uniform_random_value<theTypeYouWant>(aValue, anOtherValueWithAnOtherType);
// For example :
float randomFloat = uniform_random_value<float>(1u, 100.0f); // (a mix of unsigned and float)
© Copyright 2021 Ollivier Roberge