14 friend std::string to_string(
bitvector const&,
bool,
size_t);
17 typedef size_t block_type;
18 typedef size_t size_type;
19 static size_type constexpr npos =
static_cast<size_type
>(-1);
20 static block_type constexpr bits_per_block =
21 std::numeric_limits<block_type>::digits;
28 void operator&() =
delete;
33 reference(block_type& block, block_type i);
37 operator bool()
const;
38 bool operator~()
const;
48 block_type
const mask_;
64 template <
typename InputIterator>
67 bits_.insert(bits_.end(), first, last);
68 num_bits_ = bits_.size() * bits_per_block;
120 typename std::enable_if<
122 typename std::iterator_traits<Iterator>::iterator_category,
123 std::forward_iterator_tag
127 void append(Iterator first, Iterator last)
133 auto delta = std::distance(first, last);
134 bits_.reserve(
blocks() + delta);
137 bits_.back() |= (*first << excess);
140 auto b = *first++ >> (bits_per_block - excess);
141 bits_.push_back(b | (first == last ? 0 : *first << excess));
142 }
while (first != last);
146 bits_.insert(bits_.end(), first, last);
149 num_bits_ += bits_per_block * delta;
154 void append(block_type block);
161 void clear() noexcept;
166 void resize(size_type n,
bool value = false);
199 reference operator[](size_type i);
209 size_type
count() const;
217 size_type
size() const;
241 return i / bits_per_block;
247 return i % bits_per_block;
262 return bits / bits_per_block
263 +
static_cast<size_type
>(bits % bits_per_block != 0);
269 static size_type
lowest_bit(block_type block);
277 void zero_unused_bits();
287 std::vector<block_type> bits_;
306 std::string to_string(bitvector
const& b,
307 bool msb_to_lsb =
true,