jeudi 26 mai 2016

Best c++ way to choose randomly position of set bit in bitset

I have std::bitset<32> word and I want to choose randomly some bit which is 1. How can I do that without loops and counters. Is there any std::algorithm suitable for that? If it's easier I can convert the bitset to string or int and make it on the string or int.

Aucun commentaire:

Enregistrer un commentaire