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, _ULonglong >::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 (_ULonglong _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
 
_ULonglong 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 (_ULonglong)
 
static constexpr _ULonglong _Mask = (1ULL << (_Need_mask ? _Bits : 0)) - 1ULL
 

Member Typedef Documentation

template<size_t _Bits>
typedef _If<_Bits <= 32, _Uint32t, _ULonglong>::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 
445  : ptrdiff_t
446 
447  { // parameters for packing bits into words
448  _Bitsperword = (ptrdiff_t)(CHAR_BIT * sizeof (_Ty)),
449  _Words = (ptrdiff_t)(_Bits == 0
450  ? 0 : (_Bits - 1) / _Bitsperword)}; // NB: number of words - 1
Definition: bitset:449
int ptrdiff_t
Definition: vcruntime.h:199
#define CHAR_BIT
Definition: limits.h:17
Definition: bitset:448

Constructor & Destructor Documentation

template<size_t _Bits>
constexpr bitset< _Bits >::bitset ( )
inlineprivate
124  : _Array()
125  { // construct with all false values
126  }
_Ty _Array[_Words+1]
Definition: bitset:489
template<size_t _Bits>
constexpr bitset< _Bits >::bitset ( _ULonglong  _Val)
inlineprivate
135  : _Array{static_cast<_Ty>(_Need_mask ? _Val & _Mask : _Val)}
136  { // construct from bits in unsigned long long
137  }
_In_ int _Val
Definition: vcruntime_string.h:62
static constexpr bool _Need_mask
Definition: bitset:129
_Ty _Array[_Words+1]
Definition: bitset:489
static constexpr _ULonglong _Mask
Definition: bitset:132
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
150  { // construct from [_Pos, _Pos + _Count) elements in string
151  _Construct(_Str, _Pos, _Count, _E0, _E1);
152  }
void _Construct(const basic_string< _Elem, _Tr, _Alloc > &_Str, _BITSET_SIZE_TYPE _Pos, _BITSET_SIZE_TYPE _Count, _Elem _E0, _Elem _E1)
Definition: bitset:171
unsigned int _Count
Definition: xcomplex:668
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
160  { // initialize from NTBS
161  _Construct(
163  ? basic_string<_Elem>(_Ptr)
164  : basic_string<_Elem>(_Ptr, _Count),
165  0, _Count, _E0, _E1);
166  }
void _Construct(const basic_string< _Elem, _Tr, _Alloc > &_Str, _BITSET_SIZE_TYPE _Pos, _BITSET_SIZE_TYPE _Count, _Elem _E0, _Elem _E1)
Definition: bitset:171
unsigned int _Count
Definition: xcomplex:668
Definition: xstring:21

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
177  { // initialize from [_Pos, _Pos + _Count) elements in string
178  if (_Str.size() < _Pos)
179  _Xran(); // _Pos off end
180  if (_Str.size() - _Pos < _Count)
181  _Count = _Str.size() - _Pos; // trim _Count to size
182 
184  for (_Num = 0; _Num < _Count; ++_Num)
185  if (!_Tr::eq(_Str[_Pos + _Num], _E0)
186  && !_Tr::eq(_Str[_Pos + _Num], _E1))
187  _Xinv();
188 
189  if (_Bits < _Count)
190  _Count = _Bits; // trim _Count to length of bitset
191  _Tidy();
192 
193  for (_Pos += _Count, _Num = 0; _Num < _Count; ++_Num)
194  if (_Tr::eq(_Str[--_Pos], _E1))
195  set(_Num);
196  }
unsigned int _Count
Definition: xcomplex:668
void _Xran() const
Definition: bitset:484
bitset & set() _NOEXCEPT
Definition: bitset:256
void _Tidy(_Ty _Wordval=0)
Definition: bitset:452
size_type size() const _NOEXCEPT
Definition: xstring:1763
_Mybase::size_type size_type
Definition: xstring:762
void _Xinv() const
Definition: bitset:474
template<size_t _Bits>
_Ty bitset< _Bits >::_Getword ( size_t  _Wpos) const
inlineprivate
440  { // get word at _Wpos
441  return (_Array[_Wpos]);
442  }
_Ty _Array[_Words+1]
Definition: bitset:489
template<size_t _Bits>
constexpr bool bitset< _Bits >::_Subscript ( size_t  _Pos) const
inlineprivate
100  { // subscript nonmutable sequence
101  return ((_Array[_Pos / _Bitsperword]
102  & ((_Ty)1 << _Pos % _Bitsperword)) != 0);
103  }
Definition: bitset:448
_Ty _Array[_Words+1]
Definition: bitset:489
template<size_t _Bits>
void bitset< _Bits >::_Tidy ( _Ty  _Wordval = 0)
inlineprivate
453  { // set all words to _Wordval
454  for (ptrdiff_t _Wpos = _Words; 0 <= _Wpos; --_Wpos)
455  _Array[_Wpos] = _Wordval;
456  if (_Wordval != 0)
457  _Trim();
458  }
void _Trim()
Definition: bitset:460
Definition: bitset:449
int ptrdiff_t
Definition: vcruntime.h:199
_Ty _Array[_Words+1]
Definition: bitset:489
template<size_t _Bits>
void bitset< _Bits >::_Trim ( )
inlineprivate
461  { // clear any trailing bits in last word
463  }
void _Trim_if(true_type)
Definition: bitset:465
template<size_t _Bits>
void bitset< _Bits >::_Trim_if ( true_type  )
inlineprivate
466  { // bits to trim, remove them
467  _Array[_Words] &= ((_Ty)1 << _Bits % _Bitsperword) - 1;
468  }
Definition: bitset:449
Definition: bitset:448
_Ty _Array[_Words+1]
Definition: bitset:489
template<size_t _Bits>
void bitset< _Bits >::_Trim_if ( false_type  )
inlineprivate
471  { // no bits to trim, do nothing
472  }
template<size_t _Bits>
static void bitset< _Bits >::_Validate ( size_t  )
inlinestaticprivate
95  { // (don't) verify that _Pos is within bounds
96  }
template<size_t _Bits>
void bitset< _Bits >::_Xinv ( ) const
inlineprivate
475  { // report invalid string element in bitset conversion
476  _Xinvalid_argument("invalid bitset<N> char");
477  }
_CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL _Xinvalid_argument(_In_z_ const char *)
template<size_t _Bits>
void bitset< _Bits >::_Xoflo ( ) const
inlineprivate
480  { // report converted value too big to represent
481  _Xoverflow_error("bitset<N> overflow");
482  }
_CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL _Xoverflow_error(_In_z_ const char *)
template<size_t _Bits>
void bitset< _Bits >::_Xran ( ) const
inlineprivate
485  { // report bit index out of range
486  _Xout_of_range("invalid bitset<N> position");
487  }
_CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL _Xout_of_range(_In_z_ const char *)
template<size_t _Bits>
bool bitset< _Bits >::all ( ) const
inlineprivate
425  { // test if all bits set
426  return (count() == size());
427  }
constexpr size_t size() const _NOEXCEPT
Definition: bitset:380
size_t count() const _NOEXCEPT
Definition: bitset:352
template<size_t _Bits>
bool bitset< _Bits >::any ( ) const
inlineprivate
412  { // test if any bits are set
413  for (ptrdiff_t _Wpos = _Words; 0 <= _Wpos; --_Wpos)
414  if (_Array[_Wpos] != 0)
415  return (true);
416  return (false);
417  }
Definition: bitset:449
int ptrdiff_t
Definition: vcruntime.h:199
_Ty _Array[_Words+1]
Definition: bitset:489
template<size_t _Bits>
size_t bitset< _Bits >::count ( ) const
inlineprivate
353  { // count number of set bits
354  const char *const _Bitsperbyte =
355  "\0\1\1\2\1\2\2\3\1\2\2\3\2\3\3\4"
356  "\1\2\2\3\2\3\3\4\2\3\3\4\3\4\4\5"
357  "\1\2\2\3\2\3\3\4\2\3\3\4\3\4\4\5"
358  "\2\3\3\4\3\4\4\5\3\4\4\5\4\5\5\6"
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  "\2\3\3\4\3\4\4\5\3\4\4\5\4\5\5\6"
362  "\3\4\4\5\4\5\5\6\4\5\5\6\5\6\6\7"
363  "\1\2\2\3\2\3\3\4\2\3\3\4\3\4\4\5"
364  "\2\3\3\4\3\4\4\5\3\4\4\5\4\5\5\6"
365  "\2\3\3\4\3\4\4\5\3\4\4\5\4\5\5\6"
366  "\3\4\4\5\4\5\5\6\4\5\5\6\5\6\6\7"
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  "\3\4\4\5\4\5\5\6\4\5\5\6\5\6\6\7"
370  "\4\5\5\6\5\6\6\7\5\6\6\7\6\7\7\x8";
371  const unsigned char *_Ptr =
372  (const unsigned char *)(const void *)_Array;
373  const unsigned char *const _End = _Ptr + sizeof (_Array);
374  size_t _Val = 0;
375  for ( ; _Ptr != _End; ++_Ptr)
376  _Val += _Bitsperbyte[*_Ptr];
377  return (_Val);
378  }
_In_ int _Val
Definition: vcruntime_string.h:62
_Ty _Array[_Words+1]
Definition: bitset:489
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
291  { // flip all bits
292  for (ptrdiff_t _Wpos = _Words; 0 <= _Wpos; --_Wpos)
293  _Array[_Wpos] = (_Ty)~_Array[_Wpos];
294 
295  _Trim();
296  return (*this);
297  }
void _Trim()
Definition: bitset:460
Definition: bitset:449
int ptrdiff_t
Definition: vcruntime.h:199
_Ty _Array[_Words+1]
Definition: bitset:489
template<size_t _Bits>
bitset& bitset< _Bits >::flip ( size_t  _Pos)
inlineprivate
300  { // flip bit at _Pos
301  if (_Bits <= _Pos)
302  _Xran(); // _Pos off end
303  _Array[_Pos / _Bitsperword] ^= (_Ty)1 << _Pos % _Bitsperword;
304  return (*this);
305  }
void _Xran() const
Definition: bitset:484
Definition: bitset:448
_Ty _Array[_Words+1]
Definition: bitset:489
template<size_t _Bits>
size_t bitset< _Bits >::hash ( ) const
inlineprivate
386  { // hash bits to size_t value by pseudorandomizing transform
387  return (_Hash_seq((const unsigned char *)_Array,
388  sizeof (_Array)));
389  }
_STD_BEGIN size_t _Hash_seq(const unsigned char *_First, size_t _Count)
Definition: xstddef:335
_Ty _Array[_Words+1]
Definition: bitset:489
template<size_t _Bits>
bool bitset< _Bits >::none ( ) const
inlineprivate
420  { // test if no bits are set
421  return (!any());
422  }
bool any() const _NOEXCEPT
Definition: bitset:411
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
400  { // test for bitset inequality
401  return (!(*this == _Right));
402  }
template<size_t _Bits>
bitset& bitset< _Bits >::operator&= ( const bitset< _Bits > &  _Right)
inlineprivate
199  { // AND in _Right
200  for (ptrdiff_t _Wpos = _Words; 0 <= _Wpos; --_Wpos)
201  _Array[_Wpos] &= _Right._Getword(_Wpos);
202  return (*this);
203  }
Definition: bitset:449
int ptrdiff_t
Definition: vcruntime.h:199
_Ty _Array[_Words+1]
Definition: bitset:489
_Ty _Getword(size_t _Wpos) const
Definition: bitset:439
template<size_t _Bits>
bitset bitset< _Bits >::operator<< ( size_t  _Pos) const
inlineprivate
430  { // return bitset shifted left by _Pos
431  return (bitset(*this) <<= _Pos);
432  }
constexpr bitset() _NOEXCEPT
Definition: bitset:123
template<size_t _Bits>
bitset& bitset< _Bits >::operator<<= ( size_t  _Pos)
inlineprivate
220  { // shift left by _Pos
221  const ptrdiff_t _Wordshift = (ptrdiff_t)(_Pos / _Bitsperword);
222  if (_Wordshift != 0)
223  for (ptrdiff_t _Wpos = _Words; 0 <= _Wpos; --_Wpos)
224  _Array[_Wpos] = _Wordshift <= _Wpos // shift by words
225  ? _Array[_Wpos - _Wordshift] : (_Ty)0;
226 
227  if ((_Pos %= _Bitsperword) != 0)
228  { // 0 < _Pos < _Bitsperword, shift by bits
229  for (ptrdiff_t _Wpos = _Words; 0 < _Wpos; --_Wpos)
230  _Array[_Wpos] = (_Ty)((_Array[_Wpos] << _Pos)
231  | (_Array[_Wpos - 1] >> (_Bitsperword - _Pos)));
232  _Array[0] <<= _Pos;
233  }
234  _Trim();
235  return (*this);
236  }
void _Trim()
Definition: bitset:460
Definition: bitset:449
int ptrdiff_t
Definition: vcruntime.h:199
Definition: bitset:448
_Ty _Array[_Words+1]
Definition: bitset:489
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
392  { // test for bitset equality
393  for (ptrdiff_t _Wpos = _Words; 0 <= _Wpos; --_Wpos)
394  if (_Array[_Wpos] != _Right._Getword(_Wpos))
395  return (false);
396  return (true);
397  }
Definition: bitset:449
int ptrdiff_t
Definition: vcruntime.h:199
_Ty _Array[_Words+1]
Definition: bitset:489
_Ty _Getword(size_t _Wpos) const
Definition: bitset:439
template<size_t _Bits>
bitset bitset< _Bits >::operator>> ( size_t  _Pos) const
inlineprivate
435  { // return bitset shifted right by _Pos
436  return (bitset(*this) >>= _Pos);
437  }
constexpr bitset() _NOEXCEPT
Definition: bitset:123
template<size_t _Bits>
bitset& bitset< _Bits >::operator>>= ( size_t  _Pos)
inlineprivate
239  { // shift right by _Pos, first by words then by bits
240  const ptrdiff_t _Wordshift = (ptrdiff_t)(_Pos / _Bitsperword);
241  if (_Wordshift != 0)
242  for (ptrdiff_t _Wpos = 0; _Wpos <= _Words; ++_Wpos)
243  _Array[_Wpos] = _Wordshift <= _Words - _Wpos
244  ? _Array[_Wpos + _Wordshift] : (_Ty)0;
245 
246  if ((_Pos %= _Bitsperword) != 0)
247  { // 0 < _Pos < _Bitsperword, shift by bits
248  for (ptrdiff_t _Wpos = 0; _Wpos < _Words; ++_Wpos)
249  _Array[_Wpos] = (_Ty)((_Array[_Wpos] >> _Pos)
250  | (_Array[_Wpos + 1] << (_Bitsperword - _Pos)));
251  _Array[_Words] >>= _Pos;
252  }
253  return (*this);
254  }
Definition: bitset:449
int ptrdiff_t
Definition: vcruntime.h:199
Definition: bitset:448
_Ty _Array[_Words+1]
Definition: bitset:489
template<size_t _Bits>
constexpr bool bitset< _Bits >::operator[] ( size_t  _Pos) const
inlineprivate
106  { // subscript nonmutable sequence
107  #if _ITERATOR_DEBUG_LEVEL == 0
108  return (_Subscript(_Pos));
109 
110  #else /* _ITERATOR_DEBUG_LEVEL == 0 */
111  return (_Bits <= _Pos
112  ? (_Validate(_Pos), false)
113  : _Subscript(_Pos));
114  #endif /* _ITERATOR_DEBUG_LEVEL == 0 */
115  }
constexpr bool _Subscript(size_t _Pos) const
Definition: bitset:99
static void _Validate(size_t)
Definition: bitset:94
template<size_t _Bits>
reference bitset< _Bits >::operator[] ( size_t  _Pos)
inlineprivate
118  { // subscript mutable sequence
119  _Validate(_Pos);
120  return (reference(*this, _Pos));
121  }
static void _Validate(size_t)
Definition: bitset:94
reference() _NOEXCEPT
Definition: bitset:66
template<size_t _Bits>
bitset& bitset< _Bits >::operator^= ( const bitset< _Bits > &  _Right)
inlineprivate
213  { // XOR in _Right
214  for (ptrdiff_t _Wpos = _Words; 0 <= _Wpos; --_Wpos)
215  _Array[_Wpos] ^= _Right._Getword(_Wpos);
216  return (*this);
217  }
Definition: bitset:449
int ptrdiff_t
Definition: vcruntime.h:199
_Ty _Array[_Words+1]
Definition: bitset:489
_Ty _Getword(size_t _Wpos) const
Definition: bitset:439
template<size_t _Bits>
bitset& bitset< _Bits >::operator|= ( const bitset< _Bits > &  _Right)
inlineprivate
206  { // OR in _Right
207  for (ptrdiff_t _Wpos = _Words; 0 <= _Wpos; --_Wpos)
208  _Array[_Wpos] |= _Right._Getword(_Wpos);
209  return (*this);
210  }
Definition: bitset:449
int ptrdiff_t
Definition: vcruntime.h:199
_Ty _Array[_Words+1]
Definition: bitset:489
_Ty _Getword(size_t _Wpos) const
Definition: bitset:439
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
286  { // flip all bits
287  return (bitset(*this).flip());
288  }
constexpr bitset() _NOEXCEPT
Definition: bitset:123
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
275  { // set all bits false
276  _Tidy();
277  return (*this);
278  }
void _Tidy(_Ty _Wordval=0)
Definition: bitset:452
template<size_t _Bits>
bitset& bitset< _Bits >::reset ( size_t  _Pos)
inlineprivate
281  { // set bit at _Pos to false
282  return (set(_Pos, false));
283  }
bitset & set() _NOEXCEPT
Definition: bitset:256
template<size_t _Bits>
bitset& bitset< _Bits >::set ( )
inlineprivate
257  { // set all bits true
258  _Tidy((_Ty)~0);
259  return (*this);
260  }
void _Tidy(_Ty _Wordval=0)
Definition: bitset:452
template<size_t _Bits>
bitset& bitset< _Bits >::set ( size_t  _Pos,
bool  _Val = true 
)
inlineprivate
264  { // set bit at _Pos to _Val
265  if (_Bits <= _Pos)
266  _Xran(); // _Pos off end
267  if (_Val)
268  _Array[_Pos / _Bitsperword] |= (_Ty)1 << _Pos % _Bitsperword;
269  else
270  _Array[_Pos / _Bitsperword] &= ~((_Ty)1 << _Pos % _Bitsperword);
271  return (*this);
272  }
_In_ int _Val
Definition: vcruntime_string.h:62
void _Xran() const
Definition: bitset:484
Definition: bitset:448
_Ty _Array[_Words+1]
Definition: bitset:489
template<size_t _Bits>
constexpr size_t bitset< _Bits >::size ( ) const
inlineprivate
381  { // return size of bitset
382  return (_Bits);
383  }
template<size_t _Bits>
bool bitset< _Bits >::test ( size_t  _Pos) const
inlineprivate
405  { // test if bit at _Pos is set
406  if (_Bits <= _Pos)
407  _Xran(); // _Pos off end
408  return (_Subscript(_Pos));
409  }
void _Xran() const
Definition: bitset:484
constexpr bool _Subscript(size_t _Pos) const
Definition: bitset:99
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
339  { // convert bitset to string
342  _Str.reserve(_Bits);
343 
344  for (_Pos = _Bits; 0 < _Pos; )
345  if (test(--_Pos))
346  _Str += _E1;
347  else
348  _Str += _E0;
349  return (_Str);
350  }
void reserve(size_type _Newcap=0)
Definition: xstring:1792
_Mybase::size_type size_type
Definition: xstring:762
Definition: xstring:21
bool test(size_t _Pos) const
Definition: bitset:404
template<size_t _Bits>
_ULonglong bitset< _Bits >::to_ullong ( ) const
inlineprivate
317  { // convert bitset to unsigned long long
318  static_assert(sizeof (_ULonglong) % sizeof (_Ty) == 0,
319  "unsigned long long not multiple of _Ty");
320 
321  ptrdiff_t _Wpos = _Words;
322  for (; (ptrdiff_t)(sizeof (_ULonglong) / sizeof (_Ty)) <= _Wpos;
323  --_Wpos)
324  if (_Array[_Wpos] != 0)
325  _Xoflo(); // fail if any high-order words are nonzero
326 
327  _ULonglong _Val = _Array[_Wpos];
328  for (; 0 <= --_Wpos; )
329  _Val = ((_Val << (_Bitsperword - 1)) << 1) | _Array[_Wpos];
330  return (_Val);
331  }
void _Xoflo() const
Definition: bitset:479
Definition: bitset:449
_In_ int _Val
Definition: vcruntime_string.h:62
int ptrdiff_t
Definition: vcruntime.h:199
Definition: bitset:448
_Ty _Array[_Words+1]
Definition: bitset:489
_ULONGLONG _ULonglong
Definition: yvals.h:593
template<size_t _Bits>
unsigned long bitset< _Bits >::to_ulong ( ) const
inlineprivate
308  { // convert bitset to unsigned long
310  unsigned long _Ans = (unsigned long)_Val;
311  if (_Ans != _Val)
312  _Xoflo();
313  return (_Ans);
314  }
void _Xoflo() const
Definition: bitset:479
_ULonglong to_ullong() const
Definition: bitset:316
_In_ int _Val
Definition: vcruntime_string.h:62
_ULONGLONG _ULonglong
Definition: yvals.h:593

Member Data Documentation

template<size_t _Bits>
_Ty bitset< _Bits >::_Array[_Words+1]
private
template<size_t _Bits>
constexpr _ULonglong 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 (_ULonglong)
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: