int number_ex(int from, int to, const char *file, int line)
{
// We only need (and want) to initialize the mersenne twister generator once
static std::random_device rd;
static std::mt19937 mt(rd());
static std::uniform_int_distribution<int> dist; // not too expensive to create, though
if (from > to)
{
int tmp = from;
sys_err("number(): first argument is bigger than second argument %d -> %d, %s %d", from, to, file, line);
from = to;
to = tmp;
}
// Set the range we'd like our distribution to be on, and generate the number
return dist(mt, std::uniform_int_distribution<int>::param_type(from, to));
}