有没有一种方法可以有效地从位集中提取 CPU 字长长的位子序列,而无需单独迭代每个位?就像是
#include <bitset>
#include <iostream>
using namespace std;
int main() {
bitset<100> b;
// Do something with b
// ...
// Now i want sizeof(long) many bits starting at position 50
unsigned long l = (b>>50).to_ulong();
}
如果它会截断位串而不是抛出异常,就会这样做!