I am messing around with the std::random_device and std::mt19937_64 classes with the following piece of code. But for some unknown reasons when I start the program it always throw me the same value.
// Random.h content
#pragma once
#include <random>
#include <cstdint>
#include <cassert>
namespace localrandom
{
std::random_device randomDevice;
std::mt19937_64 twisterEngine { randomDevice() };
}
template<typename T, template<typename, typename...> class DISTRIBUTION>
T randomGet(T const& min, T const& max)
{
assert(max > min);
DISTRIBUTION<T> distribution(min, max);
return distribution(localrandom::twisterEngine);
}
template<typename T, template<typename, typename...> class DISTRIBUTION>
void randomFill(T* buffer, uint32_t const count, T const& min, T const& max)
{
assert(buffer);
assert(count);
assert(max > min);
DISTRIBUTION<T> distribution(min, max);
for (uint32_t bufferLocation = 0; bufferLocation < count; ++bufferLocation)
buffer[bufferLocation] = distribution(localrandom::twisterEngine);
}
According to random_device()'s documentation it might be due to the implementation and as I am developing on Vita using VitaSDK.... That might be the culprit but how can I know for sure ? Am I missing something here ? Is my code wrong ?
EDIT : I use WSL (Debian) as my development environment.
Aucun commentaire:
Enregistrer un commentaire