mercredi 19 octobre 2016

assigning values to a bitset from multiple int types

I am using a bitset that is created in the following way

std::bitset<4> bitset;

I wanted to know how I can assign a value to a bitset if I have ints with the values A=0,B=1,C=1,D=0 ?

I have read that I could do this

bitset.set(0, false);
bitset.set(1, true);
bitset.set(2, true);
bitset.set(3, false);

I wanted to know if there was a faster way for this ? Preferably a single statement ?

Aucun commentaire:

Enregistrer un commentaire