Skip to content

Instantly share code, notes, and snippets.

@rakin406
Last active November 29, 2023 18:55
Show Gist options
  • Select an option

  • Save rakin406/b26ac098219bb79069b0be14d7a838a3 to your computer and use it in GitHub Desktop.

Select an option

Save rakin406/b26ac098219bb79069b0be14d7a838a3 to your computer and use it in GitHub Desktop.
C++ random number generation function
int getRandomValue(int min, int max)
{
static std::random_device rd {};
static std::mt19937 mt { rd() };
std::uniform_int_distribution<std::mt19937::result_type> dist(min, max);
return dist(mt);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment