29 #ifndef _GLIBCXX_DEBUG_BITSET
30 #define _GLIBCXX_DEBUG_BITSET
36 namespace std _GLIBCXX_VISIBILITY(default)
43 :
public _GLIBCXX_STD_C::bitset<_Nb>
44 #if __cplusplus < 201103L
48 typedef _GLIBCXX_STD_C::bitset<_Nb>
_Base;
54 #if __cplusplus >= 201103L
55 typedef typename _Base::reference reference;
59 :
private _Base::reference
62 typedef typename _Base::reference _Base_ref;
67 reference(
const _Base_ref&
__base,
68 bitset* __seq __attribute__((__unused__))) _GLIBCXX_NOEXCEPT
70 , _Safe_iterator_base(__seq,
false)
74 reference(
const reference& __x) _GLIBCXX_NOEXCEPT
76 , _Safe_iterator_base(__x,
false)
80 operator=(
bool __x) _GLIBCXX_NOEXCEPT
82 _GLIBCXX_DEBUG_VERIFY(! this->_M_singular(),
83 _M_message(__gnu_debug::__msg_bad_bitset_write)
85 *
static_cast<_Base_ref*
>(
this) = __x;
90 operator=(
const reference& __x) _GLIBCXX_NOEXCEPT
92 _GLIBCXX_DEBUG_VERIFY(! __x._M_singular(),
93 _M_message(__gnu_debug::__msg_bad_bitset_read)
95 _GLIBCXX_DEBUG_VERIFY(! this->_M_singular(),
96 _M_message(__gnu_debug::__msg_bad_bitset_write)
98 *
static_cast<_Base_ref*
>(
this) = __x;
105 _GLIBCXX_DEBUG_VERIFY(! this->_M_singular(),
106 _M_message(__gnu_debug::__msg_bad_bitset_read)
107 ._M_iterator(*
this));
108 return ~(*
static_cast<const _Base_ref*
>(
this));
111 operator bool()
const _GLIBCXX_NOEXCEPT
113 _GLIBCXX_DEBUG_VERIFY(! this->_M_singular(),
114 _M_message(__gnu_debug::__msg_bad_bitset_read)
115 ._M_iterator(*
this));
116 return *
static_cast<const _Base_ref*
>(
this);
120 flip() _GLIBCXX_NOEXCEPT
122 _GLIBCXX_DEBUG_VERIFY(! this->_M_singular(),
123 _M_message(__gnu_debug::__msg_bad_bitset_flip)
124 ._M_iterator(*
this));
132 _GLIBCXX_CONSTEXPR
bitset() _GLIBCXX_NOEXCEPT
135 #if __cplusplus >= 201103L
136 constexpr
bitset(
unsigned long long __val) noexcept
138 bitset(
unsigned long __val)
142 template<
typename _CharT,
typename _Traits,
typename _Alloc>
145 typename std::basic_string<_CharT, _Traits, _Alloc>::size_type
147 typename std::basic_string<_CharT, _Traits, _Alloc>::size_type
149 :
_Base(__str, __pos, __n) { }
153 template<
class _CharT,
class _Traits,
class _Alloc>
155 typename std::basic_string<_CharT, _Traits, _Alloc>::size_type
157 typename std::basic_string<_CharT, _Traits, _Alloc>::size_type
159 _CharT __zero, _CharT __one = _CharT(
'1'))
160 :
_Base(__str, __pos, __n, __zero, __one) { }
164 #if __cplusplus >= 201103L
165 template<
typename _CharT>
167 bitset(
const _CharT* __str,
168 typename std::basic_string<_CharT>::size_type __n
170 _CharT __zero = _CharT(
'0'), _CharT __one = _CharT(
'1'))
171 :
_Base(__str, __n, __zero, __one) { }
176 operator&=(
const bitset<_Nb>& __rhs) _GLIBCXX_NOEXCEPT
183 operator|=(
const bitset<_Nb>& __rhs) _GLIBCXX_NOEXCEPT
190 operator^=(
const bitset<_Nb>& __rhs) _GLIBCXX_NOEXCEPT
211 set() _GLIBCXX_NOEXCEPT
220 set(
size_t __pos,
bool __val =
true)
227 reset() _GLIBCXX_NOEXCEPT
242 {
return bitset(~_M_base()); }
245 flip() _GLIBCXX_NOEXCEPT
264 __glibcxx_check_subscript(__pos);
265 #if __cplusplus >= 201103L
266 return _M_base()[__pos];
268 return reference(_M_base()[__pos],
this);
274 _GLIBCXX_CONSTEXPR
bool
277 #if __cplusplus < 201103L
279 __glibcxx_check_subscript(__pos);
285 #if __cplusplus >= 201103L
286 using _Base::to_ullong;
289 template <
typename _CharT,
typename _Traits,
typename _Alloc>
292 {
return _M_base().template to_string<_CharT, _Traits, _Alloc>(); }
296 template<
class _CharT,
class _Traits,
class _Alloc>
298 to_string(_CharT __zero, _CharT __one = _CharT(
'1'))
const
300 return _M_base().template
301 to_string<_CharT, _Traits, _Alloc>(__zero, __one);
306 template<
typename _CharT,
typename _Traits>
309 {
return to_string<_CharT, _Traits, std::allocator<_CharT> >(); }
313 template<
class _CharT,
class _Traits>
315 to_string(_CharT __zero, _CharT __one = _CharT(
'1'))
const
319 template<
typename _CharT>
324 return to_string<_CharT, std::char_traits<_CharT>,
328 template<
class _CharT>
331 to_string(_CharT __zero, _CharT __one = _CharT(
'1'))
const
333 return to_string<_CharT, std::char_traits<_CharT>,
344 to_string(
char __zero,
char __one =
'1')
const
346 return to_string<char, std::char_traits<char>,
354 operator==(
const bitset<_Nb>& __rhs)
const _GLIBCXX_NOEXCEPT
355 {
return _M_base() == __rhs; }
358 operator!=(
const bitset<_Nb>& __rhs)
const _GLIBCXX_NOEXCEPT
359 {
return _M_base() != __rhs; }
367 operator<<(
size_t __pos)
const _GLIBCXX_NOEXCEPT
371 operator>>(
size_t __pos)
const _GLIBCXX_NOEXCEPT
375 _M_base() _GLIBCXX_NOEXCEPT
379 _M_base()
const _GLIBCXX_NOEXCEPT
390 operator|(
const bitset<_Nb>& __x,
const bitset<_Nb>& __y) _GLIBCXX_NOEXCEPT
391 {
return bitset<_Nb>(__x) |= __y; }
395 operator^(
const bitset<_Nb>& __x,
const bitset<_Nb>& __y) _GLIBCXX_NOEXCEPT
396 {
return bitset<_Nb>(__x) ^= __y; }
398 template<
typename _CharT,
typename _Traits,
size_t _Nb>
401 {
return __is >> __x._M_base(); }
403 template<
typename _CharT,
typename _Traits,
size_t _Nb>
405 operator<<(std::basic_ostream<_CharT, _Traits>& __os,
406 const bitset<_Nb>& __x)
407 {
return __os << __x._M_base(); }
411 #if __cplusplus >= 201103L
415 struct hash<__debug::bitset<_Nb>>
416 :
public __hash_base<size_t, __debug::bitset<_Nb>>
bitset< _Nb > operator~() const noexcept
See the no-argument flip().
bitset< _Nb > operator|(const bitset< _Nb > &__x, const bitset< _Nb > &__y) noexcept
Global bitwise operations on bitsets.
Class std::bitset with additional safety/checking/debug instrumentation.
bitset< _Nb > & flip() noexcept
Toggles every bit to its opposite value.
Template class basic_istream.
bool test(size_t __position) const
Tests the value of a bit.
bitset< _Nb > & reset() noexcept
Sets every bit to false.
constexpr size_t size() const noexcept
Returns the total number of bits.
bitset< _Nb > & operator<<=(size_t __position) noexcept
bool all() const noexcept
Tests whether all the bits are on.
bitset< _Nb > operator<<(size_t __position) const noexcept
Self-explanatory.
Base class that supports tracking of iterators that reference a sequence.
size_t count() const noexcept
Returns the number of bits which are set.
unsigned long to_ulong() const
Returns a numerical interpretation of the bitset.
bitset< _Nb > & set() noexcept
Sets every bit to true.
bitset< _Nb > & operator>>=(size_t __position) noexcept
bool any() const noexcept
Tests whether any of the bits are on.
Basic functionality for a safe iterator.
std::basic_string< _CharT, _Traits, _Alloc > to_string() const
Returns a character interpretation of the bitset.
The standard allocator, as per [20.4].
bool none() const noexcept
Tests whether any of the bits are on.
bitset< _Nb > operator>>(size_t __position) const noexcept
Self-explanatory.
bitset< _Nb > operator&(const bitset< _Nb > &__x, const bitset< _Nb > &__y) noexcept
Global bitwise operations on bitsets.
_Siter_base< _Iterator >::iterator_type __base(_Iterator __it)
Managing sequences of characters and character-like objects.
Template class basic_ostream.
Primary class template hash.
bitset< _Nb > operator^(const bitset< _Nb > &__x, const bitset< _Nb > &__y) noexcept
Global bitwise operations on bitsets.
reference operator[](size_t __position)
Array-indexing support.