API 不允许对不同大小的 dynamic_bitsets 应用逻辑操作,而我的应用程序要求如果其中一个位集大于另一个,则相应地调整结果大小。我必须创建一个临时副本来解决问题:
using column_mask = boost::dynamic_bitset<uint64_t>;
void column_mask_union(column_mask& to, const column_mask& with) {
if (to.size() > with.size()) {
if (with.size()) {
column_mask tmp = with;
tmp.resize(to.size());
to |= tmp;
}
return;
}
if (to.size() < with.size()) {
to.resize(with.size());
}
to |= with;
}
我可以在 API 中看到函数 to_block_range() 和 from_block_range() 理论上可用于访问位集,但它们似乎太有限而无法实现不同大小的位集的逻辑或。