My code is failing as to not recognize "generator", but I declare it at the top of my C++ file. I need it to be thread-safe, so I declared it with "thread_local":
#include <windows.h>
#include <iostream>
#include <random>
using namespace std;
thread_local mt19937 generator;
DWORD GenerateRandomNumber(DWORD dwMin, DWORD dwMax)
{
uniform_int_distribution <DWORD> distribution(dwMin, dwMax);
return distribution(generator);
}
int main()
{
random_device rd;
generator(rd());
}
Aucun commentaire:
Enregistrer un commentaire