jeudi 12 mars 2015

How can I save the value of std::random_device?

Im just learning how to use the library, and I have the following code:


main.cpp



int main()
{
std::random_device seed;
sf::RenderWindow window(sf::VideoMode(1280, 720), "Tetris");
window.setFramerateLimit(60);

World world(window, seed);

//...


World's constructor:



World::World(sf::RenderWindow &w, std::random_device &s)
:window(w), seed(s)
{
for (int x = 0; x < 10; x++)
for (int y = 0; y < 24; y++)
{
map[x][y] = 0;
color_map[x][y] = Color::NONE;
}
}


seed is a std::random_device member of World. Visual Studio gives the following error:



Error 1 error C2280: 'std::random_device::random_device(const std::random_device &)' : attempting to reference a deleted function



How can I save the seed? Can I convert the value of std::random_device to an int?


Thank you.





Aucun commentaire:

Enregistrer un commentaire