jeudi 16 janvier 2020

What is the best way to generate a vector of random booleans?

I am generating a std::vector<bool> of random booleans.

The way I'm doing it so far is something like this:

   static std::mt19937 generator; 
   static std::uniform_int_distribution<int> distribution(0,1);
   std::vector<bool> vec(10, false);

   for(auto val : vec) val = distribution(generator);

Is there a better or more efficient way of doing this?




Aucun commentaire:

Enregistrer un commentaire