29 #ifndef _GLIBCXX_TR2_DYNAMIC_BITSET
30 #define _GLIBCXX_TR2_DYNAMIC_BITSET 1
32 #pragma GCC system_header
44 namespace std _GLIBCXX_VISIBILITY(default)
48 _GLIBCXX_BEGIN_NAMESPACE_VERSION
66 class _Bool2UChar<bool>
69 typedef unsigned char type;
79 template<
typename _WordT =
unsigned long long,
84 "_WordT not an unsigned integral type");
86 typedef _WordT block_type;
87 typedef _Alloc allocator_type;
88 typedef size_t size_type;
90 static const size_type _S_bits_per_block = __CHAR_BIT__ *
sizeof(block_type);
91 static const size_type npos =
static_cast<size_type
>(-1);
106 __dynamic_bitset_base(size_type __nbits,
unsigned long long __val = 0ULL,
107 const allocator_type& __alloc = allocator_type())
108 :
_M_w(__nbits / _S_bits_per_block
109 + (__nbits % _S_bits_per_block > 0),
112 unsigned long long __mask = ~static_cast<block_type>(0);
114 sizeof(
unsigned long long) /
sizeof(block_type));
115 for (
size_t __i = 0; __i < __n; ++__i)
117 this->
_M_w[__i] = (__val & __mask) >> (__i * _S_bits_per_block);
118 __mask <<= _S_bits_per_block;
123 _M_assign(
const __dynamic_bitset_base& __b)
124 { this->
_M_w = __b._M_w; }
127 _M_swap(__dynamic_bitset_base& __b)
135 _M_resize(
size_t __nbits,
bool __value)
137 size_t __sz = __nbits / _S_bits_per_block;
138 if (__nbits % _S_bits_per_block > 0)
145 _M_get_allocator()
const
146 {
return this->
_M_w.get_allocator(); }
149 _S_whichword(size_type __pos)
150 {
return __pos / _S_bits_per_block; }
153 _S_whichbyte(size_type __pos)
154 {
return (__pos % _S_bits_per_block) / __CHAR_BIT__; }
157 _S_whichbit(size_type __pos)
158 {
return __pos % _S_bits_per_block; }
161 _S_maskbit(size_type __pos)
162 {
return (static_cast<block_type>(1)) << _S_whichbit(__pos); }
165 _M_getword(size_type __pos)
166 {
return this->
_M_w[_S_whichword(__pos)]; }
169 _M_getword(size_type __pos)
const
170 {
return this->
_M_w[_S_whichword(__pos)]; }
181 _M_do_and(
const __dynamic_bitset_base& __x)
183 if (__x._M_w.size() == this->
_M_w.
size())
184 for (
size_t __i = 0; __i < this->
_M_w.
size(); ++__i)
185 this->
_M_w[__i] &= __x._M_w[__i];
191 _M_do_or(
const __dynamic_bitset_base& __x)
193 if (__x._M_w.size() == this->
_M_w.
size())
194 for (
size_t __i = 0; __i < this->
_M_w.
size(); ++__i)
195 this->
_M_w[__i] |= __x._M_w[__i];
201 _M_do_xor(
const __dynamic_bitset_base& __x)
203 if (__x._M_w.size() == this->
_M_w.
size())
204 for (
size_t __i = 0; __i < this->
_M_w.
size(); ++__i)
205 this->
_M_w[__i] ^= __x._M_w[__i];
211 _M_do_dif(
const __dynamic_bitset_base& __x)
213 if (__x._M_w.size() == this->
_M_w.
size())
214 for (
size_t __i = 0; __i < this->
_M_w.
size(); ++__i)
215 this->
_M_w[__i] &= ~__x._M_w[__i];
221 _M_do_left_shift(
size_t __shift);
224 _M_do_right_shift(
size_t __shift);
229 for (
size_t __i = 0; __i < this->
_M_w.
size(); ++__i)
236 for (
size_t __i = 0; __i < this->
_M_w.
size(); ++__i)
237 this->
_M_w[__i] = ~static_cast<block_type>(0);
243 for (
size_t __i = 0; __i < this->
_M_w.
size(); ++__i)
244 this->
_M_w[__i] = static_cast<block_type>(0);
248 _M_is_equal(
const __dynamic_bitset_base& __x)
const
250 if (__x.size() == this->
size())
252 for (
size_t __i = 0; __i < this->
_M_w.
size(); ++__i)
253 if (this->
_M_w[__i] != __x._M_w[__i])
262 _M_is_less(
const __dynamic_bitset_base& __x)
const
264 if (__x.size() == this->
size())
266 for (
size_t __i = this->
_M_w.
size(); __i > 0; --__i)
268 if (this->
_M_w[__i-1] < __x._M_w[__i-1])
270 else if (this->
_M_w[__i-1] > __x._M_w[__i-1])
280 _M_are_all_aux()
const
282 for (
size_t __i = 0; __i < this->
_M_w.
size() - 1; ++__i)
283 if (
_M_w[__i] != ~static_cast<block_type>(0))
285 return ((this->
_M_w.
size() - 1) * _S_bits_per_block
286 + __builtin_popcountl(this->_M_hiword()));
292 for (
size_t __i = 0; __i < this->
_M_w.
size(); ++__i)
293 if (this->
_M_w[__i] != static_cast<block_type>(0))
299 _M_is_subset_of(
const __dynamic_bitset_base& __b)
301 if (__b.size() == this->
size())
303 for (
size_t __i = 0; __i <
_M_w.
size(); ++__i)
304 if (this->
_M_w[__i] != (this->
_M_w[__i] | __b._M_w[__i]))
313 _M_is_proper_subset_of(
const __dynamic_bitset_base& __b)
const
315 if (this->is_subset_of(__b))
330 for (
size_t __i = 0; __i < this->
_M_w.
size(); ++__i)
331 __result += __builtin_popcountl(this->
_M_w[__i]);
340 _M_do_to_ulong()
const;
343 _M_do_to_ullong()
const;
347 _M_do_find_first(
size_t __not_found)
const;
351 _M_do_find_next(
size_t __prev,
size_t __not_found)
const;
355 _M_do_append_block(block_type __block, size_type __pos)
357 size_t __offset = __pos % _S_bits_per_block;
362 this->_M_hiword() |= (__block << __offset);
363 this->
_M_w.
push_back(__block >> (_S_bits_per_block - __offset));
369 template<
typename _WordT,
typename _Alloc>
371 __dynamic_bitset_base<_WordT, _Alloc>::_M_do_left_shift(
size_t __shift)
373 if (__builtin_expect(__shift != 0, 1))
375 const size_t __wshift = __shift / _S_bits_per_block;
376 const size_t __offset = __shift % _S_bits_per_block;
379 for (
size_t __n = this->_M_w.size() - 1; __n >= __wshift; --__n)
380 this->_M_w[__n] = this->_M_w[__n - __wshift];
383 const size_t __sub_offset = _S_bits_per_block - __offset;
384 for (
size_t __n = _M_w.size() - 1; __n > __wshift; --__n)
385 this->_M_w[__n] = ((this->_M_w[__n - __wshift] << __offset)
386 | (this->_M_w[__n - __wshift - 1] >> __sub_offset));
387 this->_M_w[__wshift] = this->_M_w[0] << __offset;
395 template<
typename _WordT,
typename _Alloc>
397 __dynamic_bitset_base<_WordT, _Alloc>::_M_do_right_shift(
size_t __shift)
399 if (__builtin_expect(__shift != 0, 1))
401 const size_t __wshift = __shift / _S_bits_per_block;
402 const size_t __offset = __shift % _S_bits_per_block;
403 const size_t __limit = this->_M_w.size() - __wshift - 1;
406 for (
size_t __n = 0; __n <= __limit; ++__n)
407 this->_M_w[__n] = this->_M_w[__n + __wshift];
410 const size_t __sub_offset = (_S_bits_per_block
412 for (
size_t __n = 0; __n < __limit; ++__n)
413 this->_M_w[__n] = ((this->_M_w[__n + __wshift] >> __offset)
414 | (this->_M_w[__n + __wshift + 1] << __sub_offset));
415 this->_M_w[__limit] = this->_M_w[_M_w.size()-1] >> __offset;
423 template<
typename _WordT,
typename _Alloc>
425 __dynamic_bitset_base<_WordT, _Alloc>::_M_do_to_ulong()
const
427 size_t __n =
sizeof(
unsigned long) /
sizeof(block_type);
428 for (
size_t __i = __n; __i < this->_M_w.size(); ++__i)
430 __throw_overflow_error(__N(
"__dynamic_bitset_base::_M_do_to_ulong"));
431 unsigned long __res = 0UL;
432 for (
size_t __i = 0; __i < __n && __i < this->_M_w.size(); ++__i)
433 __res += this->_M_w[__i] << (__i * _S_bits_per_block);
437 template<
typename _WordT,
typename _Alloc>
439 __dynamic_bitset_base<_WordT, _Alloc>::_M_do_to_ullong()
const
441 size_t __n =
sizeof(
unsigned long long) /
sizeof(block_type);
442 for (
size_t __i = __n; __i < this->_M_w.size(); ++__i)
444 __throw_overflow_error(__N(
"__dynamic_bitset_base::_M_do_to_ullong"));
445 unsigned long long __res = 0ULL;
446 for (
size_t __i = 0; __i < __n && __i < this->_M_w.size(); ++__i)
447 __res += this->_M_w[__i] << (__i * _S_bits_per_block);
451 template<
typename _WordT,
typename _Alloc>
453 __dynamic_bitset_base<_WordT, _Alloc>
454 ::_M_do_find_first(
size_t __not_found)
const
456 for (
size_t __i = 0; __i < this->_M_w.size(); ++__i)
458 _WordT __thisword = this->_M_w[__i];
459 if (__thisword != static_cast<_WordT>(0))
460 return (__i * _S_bits_per_block
461 + __builtin_ctzl(__thisword));
467 template<
typename _WordT,
typename _Alloc>
469 __dynamic_bitset_base<_WordT, _Alloc>
470 ::_M_do_find_next(
size_t __prev,
size_t __not_found)
const
476 if (__prev >= this->_M_w.size() * _S_bits_per_block)
480 size_t __i = _S_whichword(__prev);
481 _WordT __thisword = this->_M_w[__i];
484 __thisword &= (~static_cast<_WordT>(0)) << _S_whichbit(__prev);
486 if (__thisword != static_cast<_WordT>(0))
487 return (__i * _S_bits_per_block
488 + __builtin_ctzl(__thisword));
491 for (++__i; __i < this->_M_w.size(); ++__i)
493 __thisword = this->_M_w[__i];
494 if (__thisword != static_cast<_WordT>(0))
495 return (__i * _S_bits_per_block
496 + __builtin_ctzl(__thisword));
568 template<
typename _WordT =
unsigned long long,
574 "_WordT not an unsigned integral type");
579 typedef _WordT block_type;
580 typedef _Alloc allocator_type;
581 typedef size_t size_type;
583 static const size_type bits_per_block = __CHAR_BIT__ *
sizeof(block_type);
585 static const size_type npos =
static_cast<size_type
>(-1);
593 size_type __shift = this->_M_Nb % bits_per_block;
595 this->_M_hiword() &= ~((~static_cast<block_type>(0)) << __shift);
603 _M_unchecked_set(size_type __pos)
605 this->_M_getword(__pos) |= _Base::_S_maskbit(__pos);
610 _M_unchecked_set(size_type __pos,
int __val)
613 this->_M_getword(__pos) |= _Base::_S_maskbit(__pos);
615 this->_M_getword(__pos) &= ~
_Base::_S_maskbit(__pos);
620 _M_unchecked_reset(size_type __pos)
622 this->_M_getword(__pos) &= ~
_Base::_S_maskbit(__pos);
627 _M_unchecked_flip(size_type __pos)
629 this->_M_getword(__pos) ^= _Base::_S_maskbit(__pos);
634 _M_unchecked_test(size_type __pos)
const
635 {
return ((this->_M_getword(__pos) & _Base::_S_maskbit(__pos))
636 != static_cast<_WordT>(0)); }
668 this->_M_wp = &__b._M_getword(__pos);
669 this->_M_bpos = _Base::_S_whichbit(__pos);
680 *this->_M_wp |= _Base::_S_maskbit(this->_M_bpos);
682 *this->_M_wp &= ~
_Base::_S_maskbit(this->_M_bpos);
690 if ((*(__j._M_wp) & _Base::_S_maskbit(__j._M_bpos)))
691 *this->_M_wp |= _Base::_S_maskbit(this->_M_bpos);
693 *this->_M_wp &= ~
_Base::_S_maskbit(this->_M_bpos);
700 {
return (*(_M_wp) & _Base::_S_maskbit(this->_M_bpos)) == 0; }
703 operator bool()
const
704 {
return (*(this->_M_wp) & _Base::_S_maskbit(this->_M_bpos)) != 0; }
710 *this->_M_wp ^= _Base::_S_maskbit(this->_M_bpos);
717 typedef bool const_reference;
723 :
_Base(__alloc), _M_Nb(0)
729 const allocator_type& __alloc = allocator_type())
730 :
_Base(__nbits, __val, __alloc),
735 const allocator_type& __alloc = allocator_type())
736 : _Base(__alloc), _M_Nb(0)
748 template<
typename _CharT,
typename _Traits,
typename _Alloc1>
751 typename basic_string<_CharT,_Traits,_Alloc1>::size_type
753 typename basic_string<_CharT,_Traits,_Alloc1>::size_type
755 _CharT __zero = _CharT(
'0'), _CharT __one = _CharT(
'1'),
756 const allocator_type& __alloc = allocator_type())
760 if (__pos > __str.
size())
761 __throw_out_of_range(__N(
"dynamic_bitset::bitset initial position "
765 this->_M_Nb = (__n > __str.
size() ? __str.
size() - __pos : __n);
766 this->
resize(this->_M_Nb);
767 this->_M_copy_from_string(__str, __pos, __n,
768 _CharT(
'0'), _CharT(
'1'));
779 const allocator_type& __alloc = allocator_type())
784 while (__str[__len] !=
'\0')
787 this->_M_copy_from_ptr<char,std::char_traits<char>>
788 (__str, __len, 0, __len,
'0',
'1');
812 std::swap(this->_M_Nb, __b._M_Nb);
823 this->_M_assign(__b);
824 this->_M_Nb = __b._M_Nb;
843 {
return this->_M_get_allocator(); }
849 resize(size_type __nbits,
bool __value =
false)
851 this->_M_resize(__nbits, __value);
852 this->_M_Nb = __nbits;
853 this->_M_do_sanitize();
872 if (
size_t __offset = this->
size() % bits_per_block == 0)
873 this->_M_do_append_block(block_type(0), this->_M_Nb);
875 this->_M_unchecked_set(this->_M_Nb, __bit);
884 this->_M_do_append_block(__block, this->_M_Nb);
885 this->_M_Nb += bits_per_block;
893 { this->
append(__il.begin(), __il.end()); }
898 template <
typename _BlockInputIterator>
900 append(_BlockInputIterator __first, _BlockInputIterator __last)
902 for (; __first != __last; ++__first)
917 this->_M_do_and(__rhs);
924 this->_M_do_and(std::move(__rhs));
931 this->_M_do_or(__rhs);
938 this->_M_do_xor(__rhs);
945 this->_M_do_dif(__rhs);
960 if (__builtin_expect(__pos < this->_M_Nb, 1))
962 this->_M_do_left_shift(__pos);
963 this->_M_do_sanitize();
973 if (__builtin_expect(__pos < this->_M_Nb, 1))
975 this->_M_do_right_shift(__pos);
976 this->_M_do_sanitize();
992 this->_M_do_sanitize();
1003 set(size_type __pos,
bool __val =
true)
1006 __throw_out_of_range(__N(
"dynamic_bitset::set"));
1007 return this->_M_unchecked_set(__pos, __val);
1016 this->_M_do_reset();
1031 __throw_out_of_range(__N(
"dynamic_bitset::reset"));
1032 return this->_M_unchecked_reset(__pos);
1042 this->_M_do_sanitize();
1055 __throw_out_of_range(__N(
"dynamic_bitset::flip"));
1056 return this->_M_unchecked_flip(__pos);
1079 {
return _M_unchecked_test(__pos); }
1090 {
return this->_M_do_to_ulong(); }
1100 {
return this->_M_do_to_ullong(); }
1110 template<
typename _CharT = char,
1114 to_string(_CharT __zero = _CharT(
'0'), _CharT __one = _CharT(
'1'))
const
1117 _M_copy_to_string(__result, __zero, __one);
1122 template<
typename _CharT,
typename _Traits>
1124 _M_copy_from_ptr(
const _CharT*,
size_t,
size_t,
size_t,
1127 template<
typename _CharT,
typename _Traits,
typename _Alloc1>
1130 _Traits, _Alloc1>& __str,
size_t __pos,
size_t __n,
1131 _CharT __zero = _CharT(
'0'),
1132 _CharT __one = _CharT(
'1'))
1133 { _M_copy_from_ptr<_CharT, _Traits>(__str.data(), __str.size(),
1134 __pos, __n, __zero, __one); }
1136 template<
typename _CharT,
typename _Traits,
typename _Alloc1>
1139 _CharT __zero = _CharT(
'0'),
1140 _CharT __one = _CharT(
'1'))
const;
1145 {
return this->_M_do_count(); }
1150 {
return this->_M_Nb; }
1154 {
return this->_M_size(); }
1159 {
return (this->_M_Nb == 0); }
1178 __throw_out_of_range(__N(
"dynamic_bitset::test"));
1179 return _M_unchecked_test(__pos);
1188 {
return this->_M_are_all_aux() == _M_Nb; }
1196 {
return this->_M_is_any(); }
1204 {
return !this->_M_is_any(); }
1224 {
return this->_M_do_find_first(this->_M_Nb); }
1234 {
return this->_M_do_find_next(__prev, this->_M_Nb); }
1238 {
return this->_M_is_subset_of(__b); }
1242 {
return this->_M_is_proper_subset_of(__b); }
1246 template<
typename _WordT,
typename _Alloc>
1247 template<
typename _CharT,
typename _Traits>
1249 dynamic_bitset<_WordT, _Alloc>::
1250 _M_copy_from_ptr(
const _CharT* __str,
size_t __len,
1251 size_t __pos,
size_t __n, _CharT __zero, _CharT __one)
1255 for (
size_t __i = __nbits; __i > 0; --__i)
1257 const _CharT __c = __str[__pos + __nbits - __i];
1258 if (_Traits::eq(__c, __zero))
1260 else if (_Traits::eq(__c, __one))
1261 _M_unchecked_set(__i - 1);
1263 __throw_invalid_argument(__N(
"dynamic_bitset::_M_copy_from_ptr"));
1267 template<
typename _WordT,
typename _Alloc>
1268 template<
typename _CharT,
typename _Traits,
typename _Alloc1>
1270 dynamic_bitset<_WordT, _Alloc>::
1272 _CharT __zero, _CharT __one)
const
1274 __str.
assign(_M_Nb, __zero);
1275 for (
size_t __i = _M_Nb; __i > 0; --__i)
1276 if (_M_unchecked_test(__i - 1))
1277 _Traits::assign(__str[_M_Nb - __i], __one);
1283 template<
typename _WordT,
typename _Alloc>
1287 {
return __lhs._M_is_equal(__rhs); }
1289 template<
typename _WordT,
typename _Alloc>
1293 {
return !__lhs._M_is_equal(__rhs); }
1295 template<
typename _WordT,
typename _Alloc>
1297 operator<(const dynamic_bitset<_WordT, _Alloc>& __lhs,
1299 {
return __lhs._M_is_less(__rhs); }
1301 template<
typename _WordT,
typename _Alloc>
1303 operator<=(const dynamic_bitset<_WordT, _Alloc>& __lhs,
1305 {
return !(__lhs > __rhs); }
1307 template<
typename _WordT,
typename _Alloc>
1311 {
return __rhs < __lhs; }
1313 template<
typename _WordT,
typename _Alloc>
1317 {
return !(__lhs < __rhs); }
1330 template<
typename _WordT,
typename _Alloc>
1331 inline dynamic_bitset<_WordT, _Alloc>
1340 template<
typename _WordT,
typename _Alloc>
1341 inline dynamic_bitset<_WordT, _Alloc>
1350 template <
typename _WordT,
typename _Alloc>
1351 inline dynamic_bitset<_WordT, _Alloc>
1360 template <
typename _WordT,
typename _Alloc>
1361 inline dynamic_bitset<_WordT, _Alloc>
1380 template<
typename _CharT,
typename _Traits,
1381 typename _WordT,
typename _Alloc>
1386 typedef typename _Traits::char_type char_type;
1388 typedef typename __istream_type::ios_base __ios_base;
1393 const char_type __zero = __is.
widen(
'0');
1394 const char_type __one = __is.
widen(
'1');
1396 typename __ios_base::iostate __state = __ios_base::goodbit;
1397 typename __istream_type::sentry __sentry(__is);
1404 static typename _Traits::int_type __eof = _Traits::eof();
1406 typename _Traits::int_type __c1 = __is.
rdbuf()->sbumpc();
1407 if (_Traits::eq_int_type(__c1, __eof))
1409 __state |= __ios_base::eofbit;
1414 const char_type __c2 = _Traits::to_char_type(__c1);
1415 if (_Traits::eq(__c2, __zero))
1417 else if (_Traits::eq(__c2, __one))
1420 eq_int_type(__is.
rdbuf()->sputbackc(__c2),
1423 __state |= __ios_base::failbit;
1433 __is._M_setstate(__ios_base::badbit);
1434 __throw_exception_again;
1437 { __is._M_setstate(__ios_base::badbit); }
1443 __state |= __ios_base::failbit;
1445 __x._M_copy_from_string(__tmp, static_cast<size_t>(0), __x.
size(),
1452 template <
typename _CharT,
typename _Traits,
1453 typename _WordT,
typename _Alloc>
1455 operator<<(std::basic_ostream<_CharT, _Traits>& __os,
1460 const ctype<_CharT>& __ct = use_facet<ctype<_CharT>>(__os.getloc());
1461 __x._M_copy_to_string(__tmp, __ct.
widen(
'0'), __ct.
widen(
'1'));
1462 return __os << __tmp;
1466 _GLIBCXX_END_NAMESPACE_VERSION
1470 #undef _GLIBCXX_BITSET_BITS_PER_WORD
bool empty() const
Returns true if the dynamic_bitset is empty.
bool operator==(const dynamic_bitset< _WordT, _Alloc > &__lhs, const dynamic_bitset< _WordT, _Alloc > &__rhs)
These comparisons for equality/inequality are, well, bitwise.
dynamic_bitset< _WordT, _Alloc > operator~() const
See the no-argument flip().
void push_back(_CharT __c)
Append a single character.
void setstate(iostate __state)
Sets additional flags in the error state.
void append(block_type __block)
Append a block.
bool empty() const _GLIBCXX_NOEXCEPT
The standard allocator, as per [20.4].
static constexpr _Tp max() _GLIBCXX_USE_NOEXCEPT
dynamic_bitset< _WordT, _Alloc > operator&(const dynamic_bitset< _WordT, _Alloc > &__x, const dynamic_bitset< _WordT, _Alloc > &__y)
Global bitwise operations on bitsets.
dynamic_bitset & operator=(const dynamic_bitset &__b)
Assignment.
Primary class template ctype facet.This template class defines classification and conversion function...
dynamic_bitset< _WordT, _Alloc > operator^(const dynamic_bitset< _WordT, _Alloc > &__x, const dynamic_bitset< _WordT, _Alloc > &__y)
Global bitwise operations on bitsets.
bitset< _Nb > & flip() _GLIBCXX_NOEXCEPT
Toggles every bit to its opposite value.
dynamic_bitset< _WordT, _Alloc > & reset(size_type __pos)
Sets a given bit to false.
void clear()
Clear the bitset.
dynamic_bitset< _WordT, _Alloc > operator<<(size_type __pos) const
Self-explanatory.
char_type widen(char __c) const
Widens characters.
constexpr _Tp && forward(typename std::remove_reference< _Tp >::type &__t) noexcept
Forward an lvalue.
Template class basic_ostream.This is the base class for all output streams. It provides text formatti...
bool operator!=(const dynamic_bitset< _WordT, _Alloc > &__lhs, const dynamic_bitset< _WordT, _Alloc > &__rhs)
These comparisons for equality/inequality are, well, bitwise.
size_type count() const
Returns the number of bits which are set.
bool none() const
Tests whether any of the bits are on.
dynamic_bitset< _WordT, _Alloc > & set(size_type __pos, bool __val=true)
Sets a given bit to a particular value.
void swap(dynamic_bitset &__b)
Swap with another bitset.
dynamic_bitset(dynamic_bitset &&__b)
Move constructor.
void swap(vector &__x) noexcept(_Alloc_traits::_S_nothrow_swap())
Swaps data with another vector.
The dynamic_bitset class represents a sequence of bits.
size_type size() const _GLIBCXX_NOEXCEPT
Returns the number of characters in the string, not including any null-termination.
std::vector< block_type, allocator_type > _M_w
0 is the least significant word.
size_type find_first() const
Finds the index of the first "on" bit.
char_type widen(char __c) const
Widen char to char_type.
size_type find_next(size_t __prev) const
Finds the index of the next "on" bit after prev.
basic_string & assign(const basic_string &__str)
Set value to contents of another string.
bitset< _Nb > operator~() const _GLIBCXX_NOEXCEPT
See the no-argument flip().
bool any() const
Tests whether any of the bits are on.
dynamic_bitset< _WordT, _Alloc > operator-(const dynamic_bitset< _WordT, _Alloc > &__x, const dynamic_bitset< _WordT, _Alloc > &__y)
Global bitwise operations on bitsets.
bool operator>(const dynamic_bitset< _WordT, _Alloc > &__lhs, const dynamic_bitset< _WordT, _Alloc > &__rhs)
These comparisons for equality/inequality are, well, bitwise.
bool operator>=(const dynamic_bitset< _WordT, _Alloc > &__lhs, const dynamic_bitset< _WordT, _Alloc > &__rhs)
These comparisons for equality/inequality are, well, bitwise.
void push_back(bool __bit)
Push a bit onto the high end of the bitset.
dynamic_bitset< _WordT, _Alloc > operator|(const dynamic_bitset< _WordT, _Alloc > &__x, const dynamic_bitset< _WordT, _Alloc > &__y)
Global bitwise operations on bitsets.
void clear() _GLIBCXX_NOEXCEPT
dynamic_bitset< _WordT, _Alloc > & operator&=(dynamic_bitset< _WordT, _Alloc > &&__rhs)
Operations on dynamic_bitsets.
void reserve(size_type __res_arg=0)
Attempt to preallocate enough memory for specified number of characters.
unsigned long to_ulong() const
Returns a numerical interpretation of the dynamic_bitset.
bool test(size_type __pos) const
Tests the value of a bit.
dynamic_bitset(const char *__str, const allocator_type &__alloc=allocator_type())
Construct from a string.
dynamic_bitset< _WordT, _Alloc > & operator>>=(size_type __pos)
Operations on dynamic_bitsets.
Thrown as part of forced unwinding.A magic placeholder class that can be caught by reference to recog...
size_type size() const _GLIBCXX_NOEXCEPT
bool all() const
Tests whether all the bits are on.
const _Tp & min(const _Tp &, const _Tp &)
This does what you think it does.
Template class basic_istream.This is the base class for all input streams. It provides text formattin...
dynamic_bitset< _WordT, _Alloc > & operator<<=(size_type __pos)
Operations on dynamic_bitsets.
dynamic_bitset< _WordT, _Alloc > & set()
Sets every bit to true.
dynamic_bitset & operator=(dynamic_bitset &&__b)
Move assignment.
void resize(size_type __nbits, bool __value=false)
Resize the bitset.
Managing sequences of characters and character-like objects.
dynamic_bitset< _WordT, _Alloc > operator>>(size_type __pos) const
Self-explanatory.
bitset< _Nb > & reset() _GLIBCXX_NOEXCEPT
Sets every bit to false.
basic_streambuf< _CharT, _Traits > * rdbuf() const
Accessing the underlying buffer.
Basis for explicit traits specializations.
reference operator[](size_type __pos)
Array-indexing support.
size_type size() const
Returns the total number of bits.
dynamic_bitset(size_type __nbits, unsigned long long __val=0ULL, const allocator_type &__alloc=allocator_type())
Initial bits bitwise-copied from a single word (others set to zero).
dynamic_bitset(const dynamic_bitset &__b)
Copy constructor.
std::basic_string< _CharT, _Traits, _Alloc1 > to_string(_CharT __zero=_CharT('0'), _CharT __one=_CharT('1')) const
Returns a character interpretation of the dynamic_bitset.
dynamic_bitset< _WordT, _Alloc > & operator&=(const dynamic_bitset< _WordT, _Alloc > &__rhs)
Operations on dynamic_bitsets.
std::basic_istream< _CharT, _Traits > & operator>>(std::basic_istream< _CharT, _Traits > &__is, dynamic_bitset< _WordT, _Alloc > &__x)
Global I/O operators for bitsets.
size_type num_blocks() const
Returns the total number of blocks.
void push_back(const value_type &__x)
Add data to the end of the vector.
size_type max_size() const
Returns the maximum size of a dynamic_bitset object having the same type as *this. The real answer is max() * bits_per_block but is likely to overflow.
dynamic_bitset< _WordT, _Alloc > & operator-=(const dynamic_bitset< _WordT, _Alloc > &__rhs)
Operations on dynamic_bitsets.
dynamic_bitset< _WordT, _Alloc > & reset()
Sets every bit to false.
dynamic_bitset< _WordT, _Alloc > & flip()
Toggles every bit to its opposite value.
void append(_BlockInputIterator __first, _BlockInputIterator __last)
Append an iterator range of blocks.
dynamic_bitset< _WordT, _Alloc > & flip(size_type __pos)
Toggles a given bit to its opposite value.
dynamic_bitset(const std::basic_string< _CharT, _Traits, _Alloc1 > &__str, typename basic_string< _CharT, _Traits, _Alloc1 >::size_type __pos=0, typename basic_string< _CharT, _Traits, _Alloc1 >::size_type __n=std::basic_string< _CharT, _Traits, _Alloc1 >::npos, _CharT __zero=_CharT('0'), _CharT __one=_CharT('1'), const allocator_type &__alloc=allocator_type())
Use a subset of a string.
void resize(size_type __new_size)
Resizes the vector to the specified number of elements.
dynamic_bitset< _WordT, _Alloc > & operator|=(const dynamic_bitset< _WordT, _Alloc > &__rhs)
Operations on dynamic_bitsets.
dynamic_bitset(const allocator_type &__alloc=allocator_type())
All bits set to zero.
dynamic_bitset< _WordT, _Alloc > & operator^=(const dynamic_bitset< _WordT, _Alloc > &__rhs)
Operations on dynamic_bitsets.
constexpr size_t size() const _GLIBCXX_NOEXCEPT
Returns the total number of bits.
allocator_type get_allocator() const
Return the allocator for the bitset.
const_reference operator[](size_type __pos) const
Array-indexing support.
unsigned long long to_ullong() const
Returns a numerical interpretation of the dynamic_bitset.