如何使用一组boost::dynamic_位集?
我试图使用如何使用一组boost::dynamic_位集?,boost,set,boost-dynamic-bitset,Boost,Set,Boost Dynamic Bitset,我试图使用动态\u位集对象的集,但在运行时遇到断言失败: a.out: boost/dynamic_bitset/dynamic_bitset.hpp:1291: bool boost::operator<(const boost::dynamic_bitset<Block, Allocator>&, const boost::dynamic_bitset<Block, Allocator>&)
动态\u位集
对象的集
,但在运行时遇到断言失败:
a.out: boost/dynamic_bitset/dynamic_bitset.hpp:1291:
bool boost::operator<(const boost::dynamic_bitset<Block, Allocator>&,
const boost::dynamic_bitset<Block, Allocator>&)
[with Block = long unsigned int,
Allocator = std::allocator<long unsigned int>]:
Assertion `a.size() == b.size()' failed.
a.out:boost/dynamic_bitset/dynamic_bitset.hpp:1291:
bool boost::operator断言的原因是运算符
#include <iostream>
#include <set>
#include <boost/dynamic_bitset.hpp>
int main() {
typedef boost::dynamic_bitset<> bitset;
std::set<bitset> myset;
bitset x(2, 0);
bitset y(3, 1);
myset.insert(x);
myset.insert(y);
return 0;
}
for (size_type ii = a.num_blocks(); ii > 0; --ii)
struct my_less {
bool operator()(const boost::dynamic_bitset<>& lhs,
const boost::dynamic_bitset<>& rhs) const
{
//TODO: implement custom comparison for lhs < rhs
return false;
}
};
typedef boost::dynamic_bitset<> bitset;
std::set<bitset,my_less> myset;
myset.insert( bitset(2, 0) );
myset.insert( bitset(3, 1) );