30 #ifndef _GLIBCXX_DEBUG_BITSET
31 #define _GLIBCXX_DEBUG_BITSET
37 namespace std _GLIBCXX_VISIBILITY(default)
44 :
public _GLIBCXX_STD_C::bitset<_Nb>
45 #ifndef __GXX_EXPERIMENTAL_CXX0X__
49 typedef _GLIBCXX_STD_C::bitset<_Nb>
_Base;
55 #ifdef __GXX_EXPERIMENTAL_CXX0X__
56 typedef typename _Base::reference reference;
60 :
private _Base::reference
63 typedef typename _Base::reference _Base_ref;
68 reference(
const _Base_ref&
__base,
69 bitset* __seq __attribute__((__unused__))) _GLIBCXX_NOEXCEPT
71 , _Safe_iterator_base(__seq,
false)
75 reference(
const reference& __x) _GLIBCXX_NOEXCEPT
77 , _Safe_iterator_base(__x,
false)
81 operator=(
bool __x) _GLIBCXX_NOEXCEPT
83 _GLIBCXX_DEBUG_VERIFY(! this->_M_singular(),
84 _M_message(__gnu_debug::__msg_bad_bitset_write)
86 *
static_cast<_Base_ref*
>(
this) = __x;
91 operator=(
const reference& __x) _GLIBCXX_NOEXCEPT
93 _GLIBCXX_DEBUG_VERIFY(! __x._M_singular(),
94 _M_message(__gnu_debug::__msg_bad_bitset_read)
96 _GLIBCXX_DEBUG_VERIFY(! this->_M_singular(),
97 _M_message(__gnu_debug::__msg_bad_bitset_write)
99 *
static_cast<_Base_ref*
>(
this) = __x;
106 _GLIBCXX_DEBUG_VERIFY(! this->_M_singular(),
107 _M_message(__gnu_debug::__msg_bad_bitset_read)
108 ._M_iterator(*
this));
109 return ~(*
static_cast<const _Base_ref*
>(
this));
112 operator bool()
const _GLIBCXX_NOEXCEPT
114 _GLIBCXX_DEBUG_VERIFY(! this->_M_singular(),
115 _M_message(__gnu_debug::__msg_bad_bitset_read)
116 ._M_iterator(*
this));
117 return *
static_cast<const _Base_ref*
>(
this);
121 flip() _GLIBCXX_NOEXCEPT
123 _GLIBCXX_DEBUG_VERIFY(! this->_M_singular(),
124 _M_message(__gnu_debug::__msg_bad_bitset_flip)
125 ._M_iterator(*
this));
133 _GLIBCXX_CONSTEXPR
bitset() _GLIBCXX_NOEXCEPT
136 #ifdef __GXX_EXPERIMENTAL_CXX0X__
137 constexpr
bitset(
unsigned long long __val) noexcept
139 bitset(
unsigned long __val)
143 template<
typename _CharT,
typename _Traits,
typename _Alloc>
146 typename std::basic_string<_CharT, _Traits, _Alloc>::size_type
148 typename std::basic_string<_CharT, _Traits, _Alloc>::size_type
150 :
_Base(__str, __pos, __n) { }
154 template<
class _CharT,
class _Traits,
class _Alloc>
156 typename std::basic_string<_CharT, _Traits, _Alloc>::size_type
158 typename std::basic_string<_CharT, _Traits, _Alloc>::size_type
160 _CharT __zero, _CharT __one = _CharT(
'1'))
161 :
_Base(__str, __pos, __n, __zero, __one) { }
165 #ifdef __GXX_EXPERIMENTAL_CXX0X__
166 template<
typename _CharT>
168 bitset(
const _CharT* __str,
169 typename std::basic_string<_CharT>::size_type __n
171 _CharT __zero = _CharT(
'0'), _CharT __one = _CharT(
'1'))
172 :
_Base(__str, __n, __zero, __one) { }
177 operator&=(
const bitset<_Nb>& __rhs) _GLIBCXX_NOEXCEPT
184 operator|=(
const bitset<_Nb>& __rhs) _GLIBCXX_NOEXCEPT
191 operator^=(
const bitset<_Nb>& __rhs) _GLIBCXX_NOEXCEPT
212 set() _GLIBCXX_NOEXCEPT
221 set(
size_t __pos,
bool __val =
true)
228 reset() _GLIBCXX_NOEXCEPT
243 {
return bitset(~_M_base()); }
246 flip() _GLIBCXX_NOEXCEPT
265 __glibcxx_check_subscript(__pos);
266 #ifdef __GXX_EXPERIMENTAL_CXX0X__
267 return _M_base()[__pos];
269 return reference(_M_base()[__pos],
this);
275 _GLIBCXX_CONSTEXPR
bool
278 #ifndef __GXX_EXPERIMENTAL_CXX0X__
280 __glibcxx_check_subscript(__pos);
286 #ifdef __GXX_EXPERIMENTAL_CXX0X__
287 using _Base::to_ullong;
290 template <
typename _CharT,
typename _Traits,
typename _Alloc>
293 {
return _M_base().template to_string<_CharT, _Traits, _Alloc>(); }
297 template<
class _CharT,
class _Traits,
class _Alloc>
299 to_string(_CharT __zero, _CharT __one = _CharT(
'1'))
const
301 return _M_base().template
302 to_string<_CharT, _Traits, _Alloc>(__zero, __one);
307 template<
typename _CharT,
typename _Traits>
310 {
return to_string<_CharT, _Traits, std::allocator<_CharT> >(); }
314 template<
class _CharT,
class _Traits>
316 to_string(_CharT __zero, _CharT __one = _CharT(
'1'))
const
320 template<
typename _CharT>
325 return to_string<_CharT, std::char_traits<_CharT>,
329 template<
class _CharT>
332 to_string(_CharT __zero, _CharT __one = _CharT(
'1'))
const
334 return to_string<_CharT, std::char_traits<_CharT>,
345 to_string(
char __zero,
char __one =
'1')
const
347 return to_string<char, std::char_traits<char>,
355 operator==(
const bitset<_Nb>& __rhs)
const _GLIBCXX_NOEXCEPT
356 {
return _M_base() == __rhs; }
359 operator!=(
const bitset<_Nb>& __rhs)
const _GLIBCXX_NOEXCEPT
360 {
return _M_base() != __rhs; }
368 operator<<(
size_t __pos)
const _GLIBCXX_NOEXCEPT
372 operator>>(
size_t __pos)
const _GLIBCXX_NOEXCEPT
376 _M_base() _GLIBCXX_NOEXCEPT
380 _M_base()
const _GLIBCXX_NOEXCEPT
391 operator|(
const bitset<_Nb>& __x,
const bitset<_Nb>& __y) _GLIBCXX_NOEXCEPT
392 {
return bitset<_Nb>(__x) |= __y; }
396 operator^(
const bitset<_Nb>& __x,
const bitset<_Nb>& __y) _GLIBCXX_NOEXCEPT
397 {
return bitset<_Nb>(__x) ^= __y; }
399 template<
typename _CharT,
typename _Traits,
size_t _Nb>
402 {
return __is >> __x._M_base(); }
404 template<
typename _CharT,
typename _Traits,
size_t _Nb>
406 operator<<(std::basic_ostream<_CharT, _Traits>& __os,
407 const bitset<_Nb>& __x)
408 {
return __os << __x._M_base(); }
412 #ifdef __GXX_EXPERIMENTAL_CXX0X__
416 struct hash<__debug::bitset<_Nb>>
417 :
public __hash_base<size_t, __debug::bitset<_Nb>>
_Siter_base< _Iterator >::iterator_type __base(_Iterator __it)
bool test(size_t __position) const
Tests the value of a bit.
The standard allocator, as per [20.4].
bitset< _Nb > & flip() _GLIBCXX_NOEXCEPT
Toggles every bit to its opposite value.
bitset< _Nb > operator|(const bitset< _Nb > &__x, const bitset< _Nb > &__y) _GLIBCXX_NOEXCEPT
Global bitwise operations on bitsets.
Template class basic_ostream.This is the base class for all output streams. It provides text formatti...
Class std::bitset with additional safety/checking/debug instrumentation.
std::basic_string< _CharT, _Traits, _Alloc > to_string() const
Returns a character interpretation of the bitset.
bitset< _Nb > operator~() const _GLIBCXX_NOEXCEPT
See the no-argument flip().
size_t count() const _GLIBCXX_NOEXCEPT
Returns the number of bits which are set.
Base class that supports tracking of iterators that reference a sequence.
bool all() const _GLIBCXX_NOEXCEPT
Tests whether all the bits are on.
bool none() const _GLIBCXX_NOEXCEPT
Tests whether any of the bits are on.
unsigned long to_ulong() const
Returns a numerical interpretation of the bitset.
Template class basic_istream.This is the base class for all input streams. It provides text formattin...
reference operator[](size_t __position)
Array-indexing support.
bitset< _Nb > & operator>>=(size_t __position) _GLIBCXX_NOEXCEPT
Managing sequences of characters and character-like objects.
bitset< _Nb > & reset() _GLIBCXX_NOEXCEPT
Sets every bit to false.
bitset< _Nb > & operator<<=(size_t __position) _GLIBCXX_NOEXCEPT
bool any() const _GLIBCXX_NOEXCEPT
Tests whether any of the bits are on.
Basic functionality for a safe iterator.
bitset< _Nb > operator>>(size_t __position) const _GLIBCXX_NOEXCEPT
Self-explanatory.
bitset< _Nb > operator&(const bitset< _Nb > &__x, const bitset< _Nb > &__y) _GLIBCXX_NOEXCEPT
Global bitwise operations on bitsets.
bitset< _Nb > & set() _GLIBCXX_NOEXCEPT
Sets every bit to true.
Primary class template hash.
constexpr size_t size() const _GLIBCXX_NOEXCEPT
Returns the total number of bits.