lundi 5 novembre 2018

Not able to std::shuffle?

Code is basic:

#include <iostream>
#include <vector>
#include <random>
#include <chrono>
#include <algorithm>

int main(int argc, const char *argv[]) {
    std::vector<int> mSet = { 1, 2, 3, 4 };

    auto timeSeed = std::chrono::high_resolution_clock::now().time_since_epoch().count();
    std::seed_seq ss{ uint32_t(timeSeed & 0xffffffff), uint32_t(timeSeed >> 32) };
    std::mt19937_64 rng;
    std::shuffle(mSet.begin(), mSet.end(), rng);

    for (size_t i = 0; i < mSet.size(); i++) {
        std::cout << mSet[i] << " ";
    }
}

It always show to me the same sequence. Where am I wrong?




Aucun commentaire:

Enregistrer un commentaire