STLdoc
STLdocumentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Public Types | Public Member Functions | Public Attributes | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | List of all members
bitset< _Bits > Class Template Reference

Public Types

typedef _If< _Bits<=32, _Uint32t, unsigned long long >::type _Ty;class reference{friend class bitset< _Bits >;public:~reference() _NOEXCEPT{}reference &operator=(bool _Val) _NOEXCEPT{_Pbitset-> set(_Mypos, _Val)
 

Public Member Functions

referenceoperator= (const reference &_Bitref) _NOEXCEPT
 
referenceflip () _NOEXCEPT
 
bool operator~ () const _NOEXCEPT
 
 operator bool () const _NOEXCEPT
 

Public Attributes

returnthis
 

Private Types

enum  : ptrdiff_t { _Bitsperword = (ptrdiff_t)(CHAR_BIT * sizeof (_Ty)), _Words }
 

Private Member Functions

 reference () _NOEXCEPT
 
 reference (bitset< _Bits > &_Bitset, size_t _Pos)
 
constexpr bool _Subscript (size_t _Pos) const
 
constexpr bool operator[] (size_t _Pos) const
 
reference operator[] (size_t _Pos)
 
constexpr bitset () _NOEXCEPT
 
constexpr bitset (unsigned long long _Val) _NOEXCEPT
 
template<class _Elem , class _Tr , class _Alloc >
 bitset (const basic_string< _Elem, _Tr, _Alloc > &_Str, _BITSET_SIZE_TYPE _Pos=0, _BITSET_SIZE_TYPE _Count=basic_string< _Elem, _Tr, _Alloc >::npos, _Elem _E0=(_Elem)'0', _Elem _E1=(_Elem)'1')
 
template<class _Elem >
 bitset (const _Elem *_Ptr, typename basic_string< _Elem >::size_type _Count=basic_string< _Elem >::npos, _Elem _E0=(_Elem)'0', _Elem _E1=(_Elem)'1')
 
template<class _Elem , class _Tr , class _Alloc >
void _Construct (const basic_string< _Elem, _Tr, _Alloc > &_Str, _BITSET_SIZE_TYPE _Pos, _BITSET_SIZE_TYPE _Count, _Elem _E0, _Elem _E1)
 
bitsetoperator&= (const bitset &_Right) _NOEXCEPT
 
bitsetoperator|= (const bitset &_Right) _NOEXCEPT
 
bitsetoperator^= (const bitset &_Right) _NOEXCEPT
 
bitsetoperator<<= (size_t _Pos) _NOEXCEPT
 
bitsetoperator>>= (size_t _Pos) _NOEXCEPT
 
bitsetset () _NOEXCEPT
 
bitsetset (size_t _Pos, bool _Val=true)
 
bitsetreset () _NOEXCEPT
 
bitsetreset (size_t _Pos)
 
bitset operator~ () const _NOEXCEPT
 
bitsetflip () _NOEXCEPT
 
bitsetflip (size_t _Pos)
 
unsigned long to_ulong () const
 
unsigned long long to_ullong () const
 
template<class _Elem = char, class _Tr = char_traits<_Elem>, class _Alloc = allocator<_Elem>>
basic_string< _Elem, _Tr, _Alloc > to_string (_Elem _E0=(_Elem)'0', _Elem _E1=(_Elem)'1') const
 
size_t count () const _NOEXCEPT
 
constexpr size_t size () const _NOEXCEPT
 
size_t hash () const
 
bool operator== (const bitset &_Right) const _NOEXCEPT
 
bool operator!= (const bitset &_Right) const _NOEXCEPT
 
bool test (size_t _Pos) const
 
bool any () const _NOEXCEPT
 
bool none () const _NOEXCEPT
 
bool all () const _NOEXCEPT
 
bitset operator<< (size_t _Pos) const _NOEXCEPT
 
bitset operator>> (size_t _Pos) const _NOEXCEPT
 
_Ty _Getword (size_t _Wpos) const
 
void _Tidy (_Ty _Wordval=0)
 
void _Trim ()
 
void _Trim_if (true_type)
 
void _Trim_if (false_type)
 
void _Xinv () const
 
void _Xoflo () const
 
void _Xran () const
 

Static Private Member Functions

static void _Validate (size_t)
 

Private Attributes

bitset< _Bits > * _Pbitset
 
size_t _Mypos
 
_Ty _Array [_Words+1]
 

Static Private Attributes

static constexpr bool _Need_mask = _Bits < CHAR_BIT * sizeof (unsigned long long)
 
static constexpr unsigned long long _Mask = (1ULL << (_Need_mask ? _Bits : 0)) - 1ULL
 

Member Typedef Documentation

template<size_t _Bits>
typedef _If<_Bits <= 32, _Uint32t, unsigned long long>::type _Ty; class reference { friend class bitset<_Bits>; public: ~reference() _NOEXCEPT { } reference& operator=(bool _Val) _NOEXCEPT { _Pbitset-> bitset< _Bits >::set(_Mypos, _Val)

Member Enumeration Documentation

template<size_t _Bits>
anonymous enum : ptrdiff_t
private
Enumerator
_Bitsperword 
_Words 
447  : ptrdiff_t
448 
449  { // parameters for packing bits into words
450  _Bitsperword = (ptrdiff_t)(CHAR_BIT * sizeof (_Ty)),
451  _Words = (ptrdiff_t)(_Bits == 0
452  ? 0 : (_Bits - 1) / _Bitsperword)}; // NB: number of words - 1
int ptrdiff_t
Definition: vcruntime.h:199
#define CHAR_BIT
Definition: limits.h:17
Definition: bitset:450
Definition: bitset:451

Constructor & Destructor Documentation

template<size_t _Bits>
constexpr bitset< _Bits >::bitset ( )
inlineprivate
126  : _Array()
127  { // construct with all false values
128  }
_Ty _Array[_Words+1]
Definition: bitset:491
template<size_t _Bits>
constexpr bitset< _Bits >::bitset ( unsigned long long  _Val)
inlineprivate
137  : _Array{static_cast<_Ty>(_Need_mask ? _Val & _Mask : _Val)}
138  { // construct from bits in unsigned long long
139  }
static constexpr bool _Need_mask
Definition: bitset:131
static constexpr unsigned long long _Mask
Definition: bitset:134
_Ty _Array[_Words+1]
Definition: bitset:491
_FwdIt const _Ty _Val
Definition: algorithm:1938
template<size_t _Bits>
template<class _Elem , class _Tr , class _Alloc >
bitset< _Bits >::bitset ( const basic_string< _Elem, _Tr, _Alloc > &  _Str,
_BITSET_SIZE_TYPE  _Pos = 0,
_BITSET_SIZE_TYPE  _Count = basic_string<_Elem, _Tr, _Alloc>::npos,
_Elem  _E0 = (_Elem)'0',
_Elem  _E1 = (_Elem)'1' 
)
inlineexplicitprivate
152  { // construct from [_Pos, _Pos + _Count) elements in string
153  _Construct(_Str, _Pos, _Count, _E0, _E1);
154  }
void _Construct(const basic_string< _Elem, _Tr, _Alloc > &_Str, _BITSET_SIZE_TYPE _Pos, _BITSET_SIZE_TYPE _Count, _Elem _E0, _Elem _E1)
Definition: bitset:173
_Diff _Count
Definition: algorithm:1941
template<size_t _Bits>
template<class _Elem >
bitset< _Bits >::bitset ( const _Elem *  _Ptr,
typename basic_string< _Elem >::size_type  _Count = basic_string<_Elem>::npos,
_Elem  _E0 = (_Elem)'0',
_Elem  _E1 = (_Elem)'1' 
)
inlineexplicitprivate
162  { // initialize from NTBS
163  _Construct(
165  ? basic_string<_Elem>(_Ptr)
166  : basic_string<_Elem>(_Ptr, _Count),
167  0, _Count, _E0, _E1);
168  }
void _Construct(const basic_string< _Elem, _Tr, _Alloc > &_Str, _BITSET_SIZE_TYPE _Pos, _BITSET_SIZE_TYPE _Count, _Elem _E0, _Elem _E1)
Definition: bitset:173
_Diff _Count
Definition: algorithm:1941
Definition: xstring:1866

Member Function Documentation

template<size_t _Bits>
template<class _Elem , class _Tr , class _Alloc >
void bitset< _Bits >::_Construct ( const basic_string< _Elem, _Tr, _Alloc > &  _Str,
_BITSET_SIZE_TYPE  _Pos,
_BITSET_SIZE_TYPE  _Count,
_Elem  _E0,
_Elem  _E1 
)
inlineprivate
179  { // initialize from [_Pos, _Pos + _Count) elements in string
180  if (_Str.size() < _Pos)
181  _Xran(); // _Pos off end
182  if (_Str.size() - _Pos < _Count)
183  _Count = _Str.size() - _Pos; // trim _Count to size
184 
186  for (_Num = 0; _Num < _Count; ++_Num)
187  if (!_Tr::eq(_Str[_Pos + _Num], _E0)
188  && !_Tr::eq(_Str[_Pos + _Num], _E1))
189  _Xinv();
190 
191  if (_Bits < _Count)
192  _Count = _Bits; // trim _Count to length of bitset
193  _Tidy();
194 
195  for (_Pos += _Count, _Num = 0; _Num < _Count; ++_Num)
196  if (_Tr::eq(_Str[--_Pos], _E1))
197  set(_Num);
198  }
void _Xran() const
Definition: bitset:486
bitset & set() _NOEXCEPT
Definition: bitset:258
void _Tidy(_Ty _Wordval=0)
Definition: bitset:454
size_type size() const _NOEXCEPT
Definition: xstring:3023
_Diff _Count
Definition: algorithm:1941
_Mybase::size_type size_type
Definition: xstring:1879
void _Xinv() const
Definition: bitset:476
template<size_t _Bits>
_Ty bitset< _Bits >::_Getword ( size_t  _Wpos) const
inlineprivate
442  { // get word at _Wpos
443  return (_Array[_Wpos]);
444  }
_Ty _Array[_Words+1]
Definition: bitset:491
template<size_t _Bits>
constexpr bool bitset< _Bits >::_Subscript ( size_t  _Pos) const
inlineprivate
102  { // subscript nonmutable sequence
103  return ((_Array[_Pos / _Bitsperword]
104  & ((_Ty)1 << _Pos % _Bitsperword)) != 0);
105  }
Definition: bitset:450
_Ty _Array[_Words+1]
Definition: bitset:491
template<size_t _Bits>
void bitset< _Bits >::_Tidy ( _Ty  _Wordval = 0)
inlineprivate
455  { // set all words to _Wordval
456  for (ptrdiff_t _Wpos = _Words; 0 <= _Wpos; --_Wpos)
457  _Array[_Wpos] = _Wordval;
458  if (_Wordval != 0)
459  _Trim();
460  }
void _Trim()
Definition: bitset:462
int ptrdiff_t
Definition: vcruntime.h:199
_Ty _Array[_Words+1]
Definition: bitset:491
Definition: bitset:451
template<size_t _Bits>
void bitset< _Bits >::_Trim ( )
inlineprivate
463  { // clear any trailing bits in last word
465  }
void _Trim_if(true_type)
Definition: bitset:467
template<size_t _Bits>
void bitset< _Bits >::_Trim_if ( true_type  )
inlineprivate
468  { // bits to trim, remove them
469  _Array[_Words] &= ((_Ty)1 << _Bits % _Bitsperword) - 1;
470  }
Definition: bitset:450
_Ty _Array[_Words+1]
Definition: bitset:491
Definition: bitset:451
template<size_t _Bits>
void bitset< _Bits >::_Trim_if ( false_type  )
inlineprivate
473  { // no bits to trim, do nothing
474  }
template<size_t _Bits>
static void bitset< _Bits >::_Validate ( size_t  )
inlinestaticprivate
97  { // (don't) verify that _Pos is within bounds
98  }
template<size_t _Bits>
void bitset< _Bits >::_Xinv ( ) const
inlineprivate
477  { // report invalid string element in bitset conversion
478  _Xinvalid_argument("invalid bitset<N> char");
479  }
_CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL _Xinvalid_argument(_In_z_ const char *)
template<size_t _Bits>
void bitset< _Bits >::_Xoflo ( ) const
inlineprivate
482  { // report converted value too big to represent
483  _Xoverflow_error("bitset<N> overflow");
484  }
_CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL _Xoverflow_error(_In_z_ const char *)
template<size_t _Bits>
void bitset< _Bits >::_Xran ( ) const
inlineprivate
487  { // report bit index out of range
488  _Xout_of_range("invalid bitset<N> position");
489  }
_CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL _Xout_of_range(_In_z_ const char *)
template<size_t _Bits>
bool bitset< _Bits >::all ( ) const
inlineprivate
427  { // test if all bits set
428  return (count() == size());
429  }
constexpr size_t size() const _NOEXCEPT
Definition: bitset:382
size_t count() const _NOEXCEPT
Definition: bitset:354
template<size_t _Bits>
bool bitset< _Bits >::any ( ) const
inlineprivate
414  { // test if any bits are set
415  for (ptrdiff_t _Wpos = _Words; 0 <= _Wpos; --_Wpos)
416  if (_Array[_Wpos] != 0)
417  return (true);
418  return (false);
419  }
int ptrdiff_t
Definition: vcruntime.h:199
_Ty _Array[_Words+1]
Definition: bitset:491
Definition: bitset:451
template<size_t _Bits>
size_t bitset< _Bits >::count ( ) const
inlineprivate
355  { // count number of set bits
356  const char *const _Bitsperbyte =
357  "\0\1\1\2\1\2\2\3\1\2\2\3\2\3\3\4"
358  "\1\2\2\3\2\3\3\4\2\3\3\4\3\4\4\5"
359  "\1\2\2\3\2\3\3\4\2\3\3\4\3\4\4\5"
360  "\2\3\3\4\3\4\4\5\3\4\4\5\4\5\5\6"
361  "\1\2\2\3\2\3\3\4\2\3\3\4\3\4\4\5"
362  "\2\3\3\4\3\4\4\5\3\4\4\5\4\5\5\6"
363  "\2\3\3\4\3\4\4\5\3\4\4\5\4\5\5\6"
364  "\3\4\4\5\4\5\5\6\4\5\5\6\5\6\6\7"
365  "\1\2\2\3\2\3\3\4\2\3\3\4\3\4\4\5"
366  "\2\3\3\4\3\4\4\5\3\4\4\5\4\5\5\6"
367  "\2\3\3\4\3\4\4\5\3\4\4\5\4\5\5\6"
368  "\3\4\4\5\4\5\5\6\4\5\5\6\5\6\6\7"
369  "\2\3\3\4\3\4\4\5\3\4\4\5\4\5\5\6"
370  "\3\4\4\5\4\5\5\6\4\5\5\6\5\6\6\7"
371  "\3\4\4\5\4\5\5\6\4\5\5\6\5\6\6\7"
372  "\4\5\5\6\5\6\6\7\5\6\6\7\6\7\7\x8";
373  const unsigned char *_Ptr =
374  (const unsigned char *)(const void *)_Array;
375  const unsigned char *const _End = _Ptr + sizeof (_Array);
376  size_t _Val = 0;
377  for ( ; _Ptr != _End; ++_Ptr)
378  _Val += _Bitsperbyte[*_Ptr];
379  return (_Val);
380  }
_Ty _Array[_Words+1]
Definition: bitset:491
_FwdIt const _Ty _Val
Definition: algorithm:1938
template<size_t _Bits>
reference& bitset< _Bits >::flip ( )
inline
50  { // complement stored element
51  _Pbitset->flip(_Mypos);
52  return (*this);
53  }
bitset< _Bits > * _Pbitset
Definition: bitset:76
size_t _Mypos
Definition: bitset:77
template<size_t _Bits>
bitset& bitset< _Bits >::flip ( )
inlineprivate
293  { // flip all bits
294  for (ptrdiff_t _Wpos = _Words; 0 <= _Wpos; --_Wpos)
295  _Array[_Wpos] = (_Ty)~_Array[_Wpos];
296 
297  _Trim();
298  return (*this);
299  }
void _Trim()
Definition: bitset:462
int ptrdiff_t
Definition: vcruntime.h:199
_Ty _Array[_Words+1]
Definition: bitset:491
Definition: bitset:451
template<size_t _Bits>
bitset& bitset< _Bits >::flip ( size_t  _Pos)
inlineprivate
302  { // flip bit at _Pos
303  if (_Bits <= _Pos)
304  _Xran(); // _Pos off end
305  _Array[_Pos / _Bitsperword] ^= (_Ty)1 << _Pos % _Bitsperword;
306  return (*this);
307  }
void _Xran() const
Definition: bitset:486
Definition: bitset:450
_Ty _Array[_Words+1]
Definition: bitset:491
template<size_t _Bits>
size_t bitset< _Bits >::hash ( ) const
inlineprivate
388  { // hash bits to size_t value by pseudorandomizing transform
389  return (_Hash_seq((const unsigned char *)_Array,
390  sizeof (_Array)));
391  }
_STD_BEGIN size_t _Hash_seq(const unsigned char *_First, size_t _Count)
Definition: xstddef:330
_Ty _Array[_Words+1]
Definition: bitset:491
template<size_t _Bits>
bool bitset< _Bits >::none ( ) const
inlineprivate
422  { // test if no bits are set
423  return (!any());
424  }
bool any() const _NOEXCEPT
Definition: bitset:413
template<size_t _Bits>
bitset< _Bits >::operator bool ( ) const
inline
61  { // return element
62  return (_Pbitset->test(_Mypos));
63  }
bitset< _Bits > * _Pbitset
Definition: bitset:76
size_t _Mypos
Definition: bitset:77
template<size_t _Bits>
bool bitset< _Bits >::operator!= ( const bitset< _Bits > &  _Right) const
inlineprivate
402  { // test for bitset inequality
403  return (!(*this == _Right));
404  }
template<size_t _Bits>
bitset& bitset< _Bits >::operator&= ( const bitset< _Bits > &  _Right)
inlineprivate
201  { // AND in _Right
202  for (ptrdiff_t _Wpos = _Words; 0 <= _Wpos; --_Wpos)
203  _Array[_Wpos] &= _Right._Getword(_Wpos);
204  return (*this);
205  }
int ptrdiff_t
Definition: vcruntime.h:199
_Ty _Array[_Words+1]
Definition: bitset:491
_Ty _Getword(size_t _Wpos) const
Definition: bitset:441
Definition: bitset:451
template<size_t _Bits>
bitset bitset< _Bits >::operator<< ( size_t  _Pos) const
inlineprivate
432  { // return bitset shifted left by _Pos
433  return (bitset(*this) <<= _Pos);
434  }
constexpr bitset() _NOEXCEPT
Definition: bitset:125
template<size_t _Bits>
bitset& bitset< _Bits >::operator<<= ( size_t  _Pos)
inlineprivate
222  { // shift left by _Pos
223  const ptrdiff_t _Wordshift = (ptrdiff_t)(_Pos / _Bitsperword);
224  if (_Wordshift != 0)
225  for (ptrdiff_t _Wpos = _Words; 0 <= _Wpos; --_Wpos)
226  _Array[_Wpos] = _Wordshift <= _Wpos // shift by words
227  ? _Array[_Wpos - _Wordshift] : (_Ty)0;
228 
229  if ((_Pos %= _Bitsperword) != 0)
230  { // 0 < _Pos < _Bitsperword, shift by bits
231  for (ptrdiff_t _Wpos = _Words; 0 < _Wpos; --_Wpos)
232  _Array[_Wpos] = (_Ty)((_Array[_Wpos] << _Pos)
233  | (_Array[_Wpos - 1] >> (_Bitsperword - _Pos)));
234  _Array[0] <<= _Pos;
235  }
236  _Trim();
237  return (*this);
238  }
void _Trim()
Definition: bitset:462
int ptrdiff_t
Definition: vcruntime.h:199
Definition: bitset:450
_Ty _Array[_Words+1]
Definition: bitset:491
Definition: bitset:451
template<size_t _Bits>
reference& bitset< _Bits >::operator= ( const reference _Bitref)
inline
44  { // assign reference to element
45  _Pbitset->set(_Mypos, bool(_Bitref));
46  return (*this);
47  }
bitset< _Bits > * _Pbitset
Definition: bitset:76
size_t _Mypos
Definition: bitset:77
template<size_t _Bits>
bool bitset< _Bits >::operator== ( const bitset< _Bits > &  _Right) const
inlineprivate
394  { // test for bitset equality
395  for (ptrdiff_t _Wpos = _Words; 0 <= _Wpos; --_Wpos)
396  if (_Array[_Wpos] != _Right._Getword(_Wpos))
397  return (false);
398  return (true);
399  }
int ptrdiff_t
Definition: vcruntime.h:199
_Ty _Array[_Words+1]
Definition: bitset:491
_Ty _Getword(size_t _Wpos) const
Definition: bitset:441
Definition: bitset:451
template<size_t _Bits>
bitset bitset< _Bits >::operator>> ( size_t  _Pos) const
inlineprivate
437  { // return bitset shifted right by _Pos
438  return (bitset(*this) >>= _Pos);
439  }
constexpr bitset() _NOEXCEPT
Definition: bitset:125
template<size_t _Bits>
bitset& bitset< _Bits >::operator>>= ( size_t  _Pos)
inlineprivate
241  { // shift right by _Pos, first by words then by bits
242  const ptrdiff_t _Wordshift = (ptrdiff_t)(_Pos / _Bitsperword);
243  if (_Wordshift != 0)
244  for (ptrdiff_t _Wpos = 0; _Wpos <= _Words; ++_Wpos)
245  _Array[_Wpos] = _Wordshift <= _Words - _Wpos
246  ? _Array[_Wpos + _Wordshift] : (_Ty)0;
247 
248  if ((_Pos %= _Bitsperword) != 0)
249  { // 0 < _Pos < _Bitsperword, shift by bits
250  for (ptrdiff_t _Wpos = 0; _Wpos < _Words; ++_Wpos)
251  _Array[_Wpos] = (_Ty)((_Array[_Wpos] >> _Pos)
252  | (_Array[_Wpos + 1] << (_Bitsperword - _Pos)));
253  _Array[_Words] >>= _Pos;
254  }
255  return (*this);
256  }
int ptrdiff_t
Definition: vcruntime.h:199
Definition: bitset:450
_Ty _Array[_Words+1]
Definition: bitset:491
Definition: bitset:451
template<size_t _Bits>
constexpr bool bitset< _Bits >::operator[] ( size_t  _Pos) const
inlineprivate
108  { // subscript nonmutable sequence
109  #if _ITERATOR_DEBUG_LEVEL == 0
110  return (_Subscript(_Pos));
111 
112  #else /* _ITERATOR_DEBUG_LEVEL == 0 */
113  return (_Bits <= _Pos
114  ? (_Validate(_Pos), false)
115  : _Subscript(_Pos));
116  #endif /* _ITERATOR_DEBUG_LEVEL == 0 */
117  }
constexpr bool _Subscript(size_t _Pos) const
Definition: bitset:101
static void _Validate(size_t)
Definition: bitset:96
template<size_t _Bits>
reference bitset< _Bits >::operator[] ( size_t  _Pos)
inlineprivate
120  { // subscript mutable sequence
121  _Validate(_Pos);
122  return (reference(*this, _Pos));
123  }
static void _Validate(size_t)
Definition: bitset:96
reference() _NOEXCEPT
Definition: bitset:66
template<size_t _Bits>
bitset& bitset< _Bits >::operator^= ( const bitset< _Bits > &  _Right)
inlineprivate
215  { // XOR in _Right
216  for (ptrdiff_t _Wpos = _Words; 0 <= _Wpos; --_Wpos)
217  _Array[_Wpos] ^= _Right._Getword(_Wpos);
218  return (*this);
219  }
int ptrdiff_t
Definition: vcruntime.h:199
_Ty _Array[_Words+1]
Definition: bitset:491
_Ty _Getword(size_t _Wpos) const
Definition: bitset:441
Definition: bitset:451
template<size_t _Bits>
bitset& bitset< _Bits >::operator|= ( const bitset< _Bits > &  _Right)
inlineprivate
208  { // OR in _Right
209  for (ptrdiff_t _Wpos = _Words; 0 <= _Wpos; --_Wpos)
210  _Array[_Wpos] |= _Right._Getword(_Wpos);
211  return (*this);
212  }
int ptrdiff_t
Definition: vcruntime.h:199
_Ty _Array[_Words+1]
Definition: bitset:491
_Ty _Getword(size_t _Wpos) const
Definition: bitset:441
Definition: bitset:451
template<size_t _Bits>
bool bitset< _Bits >::operator~ ( ) const
inline
56  { // return complemented element
57  return (!_Pbitset->test(_Mypos));
58  }
bitset< _Bits > * _Pbitset
Definition: bitset:76
size_t _Mypos
Definition: bitset:77
template<size_t _Bits>
bitset bitset< _Bits >::operator~ ( ) const
inlineprivate
288  { // flip all bits
289  return (bitset(*this).flip());
290  }
constexpr bitset() _NOEXCEPT
Definition: bitset:125
template<size_t _Bits>
bitset< _Bits >::reference ( )
inlineprivate
67  : _Pbitset(0), _Mypos(0)
68  { // default construct
69  }
bitset< _Bits > * _Pbitset
Definition: bitset:76
size_t _Mypos
Definition: bitset:77
template<size_t _Bits>
bitset< _Bits >::reference ( bitset< _Bits > &  _Bitset,
size_t  _Pos 
)
inlineprivate
72  : _Pbitset(&_Bitset), _Mypos(_Pos)
73  { // construct from bitset reference and position
74  }
bitset< _Bits > * _Pbitset
Definition: bitset:76
size_t _Mypos
Definition: bitset:77
template<size_t _Bits>
bitset& bitset< _Bits >::reset ( )
inlineprivate
277  { // set all bits false
278  _Tidy();
279  return (*this);
280  }
void _Tidy(_Ty _Wordval=0)
Definition: bitset:454
template<size_t _Bits>
bitset& bitset< _Bits >::reset ( size_t  _Pos)
inlineprivate
283  { // set bit at _Pos to false
284  return (set(_Pos, false));
285  }
bitset & set() _NOEXCEPT
Definition: bitset:258
template<size_t _Bits>
bitset& bitset< _Bits >::set ( )
inlineprivate
259  { // set all bits true
260  _Tidy((_Ty)~0);
261  return (*this);
262  }
void _Tidy(_Ty _Wordval=0)
Definition: bitset:454
template<size_t _Bits>
bitset& bitset< _Bits >::set ( size_t  _Pos,
bool  _Val = true 
)
inlineprivate
266  { // set bit at _Pos to _Val
267  if (_Bits <= _Pos)
268  _Xran(); // _Pos off end
269  if (_Val)
270  _Array[_Pos / _Bitsperword] |= (_Ty)1 << _Pos % _Bitsperword;
271  else
272  _Array[_Pos / _Bitsperword] &= ~((_Ty)1 << _Pos % _Bitsperword);
273  return (*this);
274  }
void _Xran() const
Definition: bitset:486
Definition: bitset:450
_Ty _Array[_Words+1]
Definition: bitset:491
_FwdIt const _Ty _Val
Definition: algorithm:1938
template<size_t _Bits>
constexpr size_t bitset< _Bits >::size ( ) const
inlineprivate
383  { // return size of bitset
384  return (_Bits);
385  }
template<size_t _Bits>
bool bitset< _Bits >::test ( size_t  _Pos) const
inlineprivate
407  { // test if bit at _Pos is set
408  if (_Bits <= _Pos)
409  _Xran(); // _Pos off end
410  return (_Subscript(_Pos));
411  }
void _Xran() const
Definition: bitset:486
constexpr bool _Subscript(size_t _Pos) const
Definition: bitset:101
template<size_t _Bits>
template<class _Elem = char, class _Tr = char_traits<_Elem>, class _Alloc = allocator<_Elem>>
basic_string<_Elem, _Tr, _Alloc> bitset< _Bits >::to_string ( _Elem  _E0 = (_Elem)'0',
_Elem  _E1 = (_Elem)'1' 
) const
inlineprivate
341  { // convert bitset to string
344  _Str.reserve(_Bits);
345 
346  for (_Pos = _Bits; 0 < _Pos; )
347  if (test(--_Pos))
348  _Str += _E1;
349  else
350  _Str += _E0;
351  return (_Str);
352  }
_Mybase::size_type size_type
Definition: xstring:1879
Definition: xstring:1866
bool test(size_t _Pos) const
Definition: bitset:406
void reserve(_CRT_GUARDOVERFLOW const size_type _Newcap=0)
Definition: xstring:3056
template<size_t _Bits>
unsigned long long bitset< _Bits >::to_ullong ( ) const
inlineprivate
319  { // convert bitset to unsigned long long
320  static_assert(sizeof (unsigned long long) % sizeof (_Ty) == 0,
321  "unsigned long long not multiple of _Ty");
322 
323  ptrdiff_t _Wpos = _Words;
324  for (; (ptrdiff_t)(sizeof (unsigned long long) / sizeof (_Ty)) <= _Wpos;
325  --_Wpos)
326  if (_Array[_Wpos] != 0)
327  _Xoflo(); // fail if any high-order words are nonzero
328 
329  unsigned long long _Val = _Array[_Wpos];
330  for (; 0 <= --_Wpos; )
331  _Val = ((_Val << (_Bitsperword - 1)) << 1) | _Array[_Wpos];
332  return (_Val);
333  }
void _Xoflo() const
Definition: bitset:481
int ptrdiff_t
Definition: vcruntime.h:199
Definition: bitset:450
_Ty _Array[_Words+1]
Definition: bitset:491
Definition: bitset:451
_FwdIt const _Ty _Val
Definition: algorithm:1938
template<size_t _Bits>
unsigned long bitset< _Bits >::to_ulong ( ) const
inlineprivate
310  { // convert bitset to unsigned long
311  unsigned long long _Val = to_ullong();
312  unsigned long _Ans = (unsigned long)_Val;
313  if (_Ans != _Val)
314  _Xoflo();
315  return (_Ans);
316  }
void _Xoflo() const
Definition: bitset:481
_In_ long
Definition: corecrt_wstdlib.h:88
unsigned long long to_ullong() const
Definition: bitset:318
_FwdIt const _Ty _Val
Definition: algorithm:1938

Member Data Documentation

template<size_t _Bits>
_Ty bitset< _Bits >::_Array[_Words+1]
private
template<size_t _Bits>
constexpr unsigned long long bitset< _Bits >::_Mask = (1ULL << (_Need_mask ? _Bits : 0)) - 1ULL
staticprivate
template<size_t _Bits>
size_t bitset< _Bits >::_Mypos
private
template<size_t _Bits>
constexpr bool bitset< _Bits >::_Need_mask = _Bits < CHAR_BIT * sizeof (unsigned long long)
staticprivate
template<size_t _Bits>
bitset<_Bits>* bitset< _Bits >::_Pbitset
private
template<size_t _Bits>
return* bitset< _Bits >::this

The documentation for this class was generated from the following file: