setのdynamic_bitsetオブジェクトを使用しようとしていますが、実行時にアサーションエラーが発生します。
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.
コードは次のとおりです。
#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;
}
dynamic_bitset挿入されたオブジェクトに同じサイズが必要なのはなぜだろうか。が機能するためoperator<には、短いビットセットの最上位ビットが暗黙的にゼロで埋められていると想定できませんでしたか?
そのセットを機能させる方法はありますdynamic_bitsetか?
unordered_setを必要としないので試してみましたoperator<が、がないのでコンパイルできませdynamic_bitsetん。また、短いビットセットでのみ機能するメンバー関数hash_valueを使用せずにそれを記述する方法がわかりません。to_ulong