STD :: BITSET重新亮相

std::bitset redeclaration

本文关键字:亮相 新亮相 BITSET STD      更新时间:2023-10-16

我想从我的bitset代表的数字中提取一个整数。但是,我不知道如何a)复制一个比特斯特,或者,b)重新构成bitset:

bitset<7> bits(5);
int newresult=bits.to_ulong();
newresult=newresult-1;
bits=bitset<7> tempbits(newresult); // of course doesn't work

重要的是,我的最终结果在 bits bitset中。如何正确执行?

bits = bitset<7>(newresult);