大家都知道bitset<25>可以分配二十五位,请问它(内部)是怎样实现的?谢谢—……n
答案:2 悬赏:30
解决时间 2021-02-11 07:28
- 提问者网友:写不出迷人情诗
- 2021-02-10 20:15
大家都知道bitset<25>可以分配二十五位,请问它(内部)是怎样实现的?谢谢—……n
最佳答案
- 二级知识专家网友:你把微笑给了谁
- 2021-02-10 20:58
VC的实现版本。。。。比SGI的难看懂一点
\VC\crt\src\bitset文件
// TEMPLATE CLASS bitset
template
class bitset
{ // store fixed-length sequence of Boolean elements
typedef unsigned long _Ty; // base type for a storage word
enum {digits = _Bits}; // extension: compile-time size()
public:
typedef bool element_type; // retained
// CLASS reference
class reference
{ // proxy for an element
friend class bitset<_Bits>;
public:
reference& operator=(bool _Val)
{ // assign Boolean to element
_Pbitset->set(_Mypos, _Val);
return (*this);
}
reference& operator=(const reference& _Bitref)
{ // assign reference to element
_Pbitset->set(_Mypos, bool(_Bitref));
return (*this);
}
reference& flip()
{ // complement stored element
_Pbitset->flip(_Mypos);
return (*this);
}
bool operator~() const
{ // return complemented element
return (!_Pbitset->test(_Mypos));
}
operator bool() const
{ // return element
return (_Pbitset->test(_Mypos));
}
private:
reference(bitset<_Bits>& _Bitset, size_t _Pos)
: _Pbitset(&_Bitset), _Mypos(_Pos)
{ // construct from bitset reference and position
}
bitset<_Bits> *_Pbitset; // pointer to the bitset
size_t _Mypos; // position of element in bitset
};
bool at(size_t _Pos) const // retained
{ // subscript nonmutable sequence with checking
if (_Bits <= _Pos)
_Xran();
return (test(_Pos));
}
reference at(size_t _Pos) // retained
{ // subscript mutable sequence with checking
if (_Bits <= _Pos)
_Xran();
return (reference(*this, _Pos));
}
bool operator[](size_t _Pos) const
{ // subscript nonmutable sequence
return (test(_Pos));
}
reference operator[](size_t _Pos)
{ // subscript mutable sequence
return (reference(*this, _Pos));
}
bitset()
{ // construct with all false values
_Tidy();
}
bitset(unsigned long _Val)
{ // construct from bits in unsigned long
_Tidy();
for (int _Wpos = 0; ; )
{ // store to one or more words
_Array[_Wpos] = _Val;
if (sizeof (unsigned long) / sizeof (_Ty) <= ++_Wpos
|| _Words < _Wpos)
break;
_Val >>= _Bitsperword;
}
_Trim();
}
#define _BITSET_SIZE_TYPE \
typename basic_string<_Elem, _Tr, _Alloc>::size_type
template
class _Tr,
class _Alloc>
explicit bitset(const basic_string<_Elem, _Tr, _Alloc>& _Str,
_BITSET_SIZE_TYPE _Pos = 0)
{ // construct from [_Pos, ...) elements in string
_Construct(_Str, _Pos,
basic_string<_Elem, _Tr, _Alloc>::npos, (_Elem)'0');
}
template
class _Tr,
class _Alloc>
explicit bitset(const basic_string<_Elem, _Tr, _Alloc>& _Str,
_BITSET_SIZE_TYPE _Pos,
_BITSET_SIZE_TYPE _Count,
_Elem _E0 = (_Elem)'0')
{ // construct from [_Pos, _Pos + _Count) elements in string
_Construct(_Str, _Pos, _Count, _E0);
}
template
class _Tr,
class _Alloc>
void _Construct(
const basic_string<_Elem, _Tr, _Alloc>& _Str,
_BITSET_SIZE_TYPE _Pos,
_BITSET_SIZE_TYPE _Count,
_Elem _E0)
{ // initialize from [_Pos, _Pos + _Count) elements in string
typename basic_string<_Elem, _Tr, _Alloc>::size_type _Num;
if (_Str.size() < _Pos)
_Xran(); // _Pos off end
if (_Str.size() - _Pos < _Count)
_Count = _Str.size() - _Pos; // trim _Count to size
if (_Bits < _Count)
_Count = _Bits; // trim _Count to length of bitset
_Tidy();
for (_Pos += _Count, _Num = 0; _Num < _Count; ++_Num)
if (_Str[--_Pos] == _E0 + 1)
set(_Num);
else if (_Str[_Pos] != _E0)
_Xinv();
}
bitset<_Bits>& operator&=(const bitset<_Bits>& _Right)
{ // AND in _Right
for (int _Wpos = _Words; 0 <= _Wpos; --_Wpos)
_Array[_Wpos] &= _Right._Getword(_Wpos);
return (*this);
}
bitset<_Bits>& operator|=(const bitset<_Bits>& _Right)
{ // OR in _Right
for (int _Wpos = _Words; 0 <= _Wpos; --_Wpos)
_Array[_Wpos] |= _Right._Getword(_Wpos);
return (*this);
}
bitset<_Bits>& operator^=(const bitset<_Bits>& _Right)
{ // XOR in _Right
for (int _Wpos = _Words; 0 <= _Wpos; --_Wpos)
_Array[_Wpos] ^= _Right._Getword(_Wpos);
return (*this);
}
bitset<_Bits>& operator<<=(size_t _Pos)
{ // shift left by _Pos
const int _Wordshift = (int)(_Pos / _Bitsperword);
if (_Wordshift != 0)
for (int _Wpos = _Words; 0 <= _Wpos; --_Wpos) // shift by words
_Array[_Wpos] = _Wordshift <= _Wpos
? _Array[_Wpos - _Wordshift] : (_Ty)0;
if (_Pos %= _Bitsperword)
{ // 0 < _Pos < _Bitsperword, shift by bits
for (int _Wpos = _Words; 0 < _Wpos; --_Wpos)
_Array[_Wpos] = (_Ty)((_Array[_Wpos] << _Pos)
| (_Array[_Wpos - 1] >> (_Bitsperword - _Pos)));
_Array[0] <<= _Pos;
}
_Trim();
return (*this);
}
bitset<_Bits>& operator>>=(size_t _Pos)
{ // shift right by _Pos
const int _Wordshift = (int)(_Pos / _Bitsperword);
if (_Wordshift != 0)
for (int _Wpos = 0; _Wpos <= _Words; ++_Wpos) // shift by words
_Array[_Wpos] = _Wordshift <= _Words - _Wpos
? _Array[_Wpos + _Wordshift] : (_Ty)0;
if (_Pos %= _Bitsperword)
{ // 0 < _Pos < _Bitsperword, shift by bits
for (int _Wpos = 0; _Wpos < _Words; ++_Wpos)
_Array[_Wpos] = (_Ty)((_Array[_Wpos] >> _Pos)
| (_Array[_Wpos + 1] << (_Bitsperword - _Pos)));
_Array[_Words] >>= _Pos;
}
return (*this);
}
bitset<_Bits>& set()
{ // set all bits true
_Tidy((_Ty)~0);
return (*this);
}
bitset<_Bits>& set(size_t _Pos,
bool _Val = true)
{ // set bit at _Pos to _Val
if (_Bits <= _Pos)
_Xran(); // _Pos off end
if (_Val)
_Array[_Pos / _Bitsperword] |= (_Ty)1 << _Pos % _Bitsperword;
else
_Array[_Pos / _Bitsperword] &= ~((_Ty)1 << _Pos % _Bitsperword);
return (*this);
}
bitset<_Bits>& reset()
{ // set all bits false
_Tidy();
return (*this);
}
bitset<_Bits>& reset(size_t _Pos)
{ // set bit at _Pos to false
return (set(_Pos, false));
}
bitset<_Bits> operator~() const
{ // flip all bits
return (bitset<_Bits>(*this).flip());
}
bitset<_Bits>& flip()
{ // flip all bits
for (int _Wpos = _Words; 0 <= _Wpos; --_Wpos)
_Array[_Wpos] = (_Ty)~_Array[_Wpos];
_Trim();
return (*this);
}
bitset<_Bits>& flip(size_t _Pos)
{ // flip bit at _Pos
if (_Bits <= _Pos)
_Xran(); // _Pos off end
_Array[_Pos / _Bitsperword] ^= (_Ty)1 << _Pos % _Bitsperword;
return (*this);
}
unsigned long to_ulong() const
{ // convert bitset to unsigned long
enum
{ // cause zero divide if unsigned long not multiple of _Ty
_Assertion = 1
/ (int)(sizeof (unsigned long) % sizeof (_Ty) == 0)};
int _Wpos = _Words;
#pragma warning(push)
#pragma warning(disable: 6295)
for (; sizeof (unsigned long) / sizeof (_Ty) <= _Wpos; --_Wpos)
if (_Array[_Wpos] != 0)
_Xoflo(); // fail if any high-order words are nonzero
#pragma warning(pop)
unsigned long _Val = _Array[_Wpos];
for (; 0 <= --_Wpos; )
_Val = ((_Val << (_Bitsperword - 1)) << 1) | _Array[_Wpos];
return (_Val);
}
template
class _Tr,
class _Alloc>
basic_string<_Elem, _Tr, _Alloc>
to_string(_Elem _E0 = (_Elem)'0') const
{ // convert bitset to string
basic_string<_Elem, _Tr, _Alloc> _Str;
typename basic_string<_Elem, _Tr, _Alloc>::size_type _Pos;
_Str.reserve(_Bits);
for (_Pos = _Bits; 0 < _Pos; )
_Str += (_Elem)(_E0 + (int)test(--_Pos));
return (_Str);
}
template
class _Tr>
basic_string<_Elem, _Tr, allocator<_Elem> >
to_string(_Elem _E0 = (_Elem)'0') const
{ // convert bitset to string
return (to_string<_Elem, _Tr, allocator<_Elem> >(_E0));
}
template
basic_string<_Elem, char_traits<_Elem>, allocator<_Elem> >
to_string(_Elem _E0 = (_Elem)'0') const
{ // convert bitset to string
return (to_string<_Elem, char_traits<_Elem>,
allocator<_Elem> >(_E0));
}
string to_string(char _E0 = (char)'0') const
{ // convert bitset to string
return (to_string, allocator >(_E0));
}
size_t count() const
{ // count number of set bits
static char _Bitsperhex[] = "\0\1\1\2\1\2\2\3\1\2\2\3\2\3\3\4";
size_t _Val = 0;
for (int _Wpos = _Words; 0 <= _Wpos; --_Wpos)
for (_Ty _Wordval = _Array[_Wpos]; _Wordval != 0; _Wordval >>= 4)
_Val += _Bitsperhex[_Wordval & 0xF];
return (_Val);
}
size_t size() const
{ // return size of bitset
return (_Bits);
}
bool operator==(const bitset<_Bits>& _Right) const
{ // test for bitset equality
for (int _Wpos = _Words; 0 <= _Wpos; --_Wpos)
if (_Array[_Wpos] != _Right._Getword(_Wpos))
return (false);
return (true);
}
bool operator!=(const bitset<_Bits>& _Right) const
{ // test for bitset inequality
return (!(*this == _Right));
}
bool test(size_t _Pos) const
{ // test if bit at _Pos is set
if (_Bits <= _Pos)
_Xran(); // _Pos off end
return ((_Array[_Pos / _Bitsperword]
& ((_Ty)1 << _Pos % _Bitsperword)) != 0);
}
bool any() const
{ // test if any bits are set
for (int _Wpos = _Words; 0 <= _Wpos; --_Wpos)
if (_Array[_Wpos] != 0)
return (true);
return (false);
}
bool none() const
{ // test if no bits are set
return (!any());
}
bitset<_Bits> operator<<(size_t _Pos) const
{ // return bitset shifted left by _Pos
return (bitset<_Bits>(*this) <<= _Pos);
}
bitset<_Bits> operator>>(size_t _Pos) const
{ // return bitset shifted right by _Pos
return (bitset<_Bits>(*this) >>= _Pos);
}
_Ty _Getword(size_t _Wpos) const
{ // get word at _Wpos
return (_Array[_Wpos]);
}
private:
enum
{ // parameters for packing bits into words
_Bitsperword = CHAR_BIT * sizeof (_Ty), // bits in each word
_Words = _Bits == 0
? 0 : (_Bits - 1) / _Bitsperword}; // NB: number of words - 1
void _Tidy(_Ty _Wordval = 0)
{ // set all words to _Wordval
for (int _Wpos = _Words; 0 <= _Wpos; --_Wpos)
_Array[_Wpos] = _Wordval;
if (_Wordval != 0)
_Trim();
}
void _Trim()
{ // clear any trailing bits in last word
if (_Bits % _Bitsperword != 0)
_Array[_Words] &= ((_Ty)1 << _Bits % _Bitsperword) - 1;
}
void _Xinv() const
{ // report invalid string element in bitset conversion
_THROW(invalid_argument, "invalid bitset char");
}
void _Xoflo() const
{ // report converted value too big to represent
_THROW(overflow_error, "bitset overflow");
}
void _Xran() const
{ // report bit index out of range
_THROW(out_of_range, "invalid bitset position");
}
_Ty _Array[_Words + 1]; // the set of bits
};
\VC\crt\src\bitset文件
// TEMPLATE CLASS bitset
template
class bitset
{ // store fixed-length sequence of Boolean elements
typedef unsigned long _Ty; // base type for a storage word
enum {digits = _Bits}; // extension: compile-time size()
public:
typedef bool element_type; // retained
// CLASS reference
class reference
{ // proxy for an element
friend class bitset<_Bits>;
public:
reference& operator=(bool _Val)
{ // assign Boolean to element
_Pbitset->set(_Mypos, _Val);
return (*this);
}
reference& operator=(const reference& _Bitref)
{ // assign reference to element
_Pbitset->set(_Mypos, bool(_Bitref));
return (*this);
}
reference& flip()
{ // complement stored element
_Pbitset->flip(_Mypos);
return (*this);
}
bool operator~() const
{ // return complemented element
return (!_Pbitset->test(_Mypos));
}
operator bool() const
{ // return element
return (_Pbitset->test(_Mypos));
}
private:
reference(bitset<_Bits>& _Bitset, size_t _Pos)
: _Pbitset(&_Bitset), _Mypos(_Pos)
{ // construct from bitset reference and position
}
bitset<_Bits> *_Pbitset; // pointer to the bitset
size_t _Mypos; // position of element in bitset
};
bool at(size_t _Pos) const // retained
{ // subscript nonmutable sequence with checking
if (_Bits <= _Pos)
_Xran();
return (test(_Pos));
}
reference at(size_t _Pos) // retained
{ // subscript mutable sequence with checking
if (_Bits <= _Pos)
_Xran();
return (reference(*this, _Pos));
}
bool operator[](size_t _Pos) const
{ // subscript nonmutable sequence
return (test(_Pos));
}
reference operator[](size_t _Pos)
{ // subscript mutable sequence
return (reference(*this, _Pos));
}
bitset()
{ // construct with all false values
_Tidy();
}
bitset(unsigned long _Val)
{ // construct from bits in unsigned long
_Tidy();
for (int _Wpos = 0; ; )
{ // store to one or more words
_Array[_Wpos] = _Val;
if (sizeof (unsigned long) / sizeof (_Ty) <= ++_Wpos
|| _Words < _Wpos)
break;
_Val >>= _Bitsperword;
}
_Trim();
}
#define _BITSET_SIZE_TYPE \
typename basic_string<_Elem, _Tr, _Alloc>::size_type
template
class _Alloc>
explicit bitset(const basic_string<_Elem, _Tr, _Alloc>& _Str,
_BITSET_SIZE_TYPE _Pos = 0)
{ // construct from [_Pos, ...) elements in string
_Construct(_Str, _Pos,
basic_string<_Elem, _Tr, _Alloc>::npos, (_Elem)'0');
}
template
class _Alloc>
explicit bitset(const basic_string<_Elem, _Tr, _Alloc>& _Str,
_BITSET_SIZE_TYPE _Pos,
_BITSET_SIZE_TYPE _Count,
_Elem _E0 = (_Elem)'0')
{ // construct from [_Pos, _Pos + _Count) elements in string
_Construct(_Str, _Pos, _Count, _E0);
}
template
class _Alloc>
void _Construct(
const basic_string<_Elem, _Tr, _Alloc>& _Str,
_BITSET_SIZE_TYPE _Pos,
_BITSET_SIZE_TYPE _Count,
_Elem _E0)
{ // initialize from [_Pos, _Pos + _Count) elements in string
typename basic_string<_Elem, _Tr, _Alloc>::size_type _Num;
if (_Str.size() < _Pos)
_Xran(); // _Pos off end
if (_Str.size() - _Pos < _Count)
_Count = _Str.size() - _Pos; // trim _Count to size
if (_Bits < _Count)
_Count = _Bits; // trim _Count to length of bitset
_Tidy();
for (_Pos += _Count, _Num = 0; _Num < _Count; ++_Num)
if (_Str[--_Pos] == _E0 + 1)
set(_Num);
else if (_Str[_Pos] != _E0)
_Xinv();
}
bitset<_Bits>& operator&=(const bitset<_Bits>& _Right)
{ // AND in _Right
for (int _Wpos = _Words; 0 <= _Wpos; --_Wpos)
_Array[_Wpos] &= _Right._Getword(_Wpos);
return (*this);
}
bitset<_Bits>& operator|=(const bitset<_Bits>& _Right)
{ // OR in _Right
for (int _Wpos = _Words; 0 <= _Wpos; --_Wpos)
_Array[_Wpos] |= _Right._Getword(_Wpos);
return (*this);
}
bitset<_Bits>& operator^=(const bitset<_Bits>& _Right)
{ // XOR in _Right
for (int _Wpos = _Words; 0 <= _Wpos; --_Wpos)
_Array[_Wpos] ^= _Right._Getword(_Wpos);
return (*this);
}
bitset<_Bits>& operator<<=(size_t _Pos)
{ // shift left by _Pos
const int _Wordshift = (int)(_Pos / _Bitsperword);
if (_Wordshift != 0)
for (int _Wpos = _Words; 0 <= _Wpos; --_Wpos) // shift by words
_Array[_Wpos] = _Wordshift <= _Wpos
? _Array[_Wpos - _Wordshift] : (_Ty)0;
if (_Pos %= _Bitsperword)
{ // 0 < _Pos < _Bitsperword, shift by bits
for (int _Wpos = _Words; 0 < _Wpos; --_Wpos)
_Array[_Wpos] = (_Ty)((_Array[_Wpos] << _Pos)
| (_Array[_Wpos - 1] >> (_Bitsperword - _Pos)));
_Array[0] <<= _Pos;
}
_Trim();
return (*this);
}
bitset<_Bits>& operator>>=(size_t _Pos)
{ // shift right by _Pos
const int _Wordshift = (int)(_Pos / _Bitsperword);
if (_Wordshift != 0)
for (int _Wpos = 0; _Wpos <= _Words; ++_Wpos) // shift by words
_Array[_Wpos] = _Wordshift <= _Words - _Wpos
? _Array[_Wpos + _Wordshift] : (_Ty)0;
if (_Pos %= _Bitsperword)
{ // 0 < _Pos < _Bitsperword, shift by bits
for (int _Wpos = 0; _Wpos < _Words; ++_Wpos)
_Array[_Wpos] = (_Ty)((_Array[_Wpos] >> _Pos)
| (_Array[_Wpos + 1] << (_Bitsperword - _Pos)));
_Array[_Words] >>= _Pos;
}
return (*this);
}
bitset<_Bits>& set()
{ // set all bits true
_Tidy((_Ty)~0);
return (*this);
}
bitset<_Bits>& set(size_t _Pos,
bool _Val = true)
{ // set bit at _Pos to _Val
if (_Bits <= _Pos)
_Xran(); // _Pos off end
if (_Val)
_Array[_Pos / _Bitsperword] |= (_Ty)1 << _Pos % _Bitsperword;
else
_Array[_Pos / _Bitsperword] &= ~((_Ty)1 << _Pos % _Bitsperword);
return (*this);
}
bitset<_Bits>& reset()
{ // set all bits false
_Tidy();
return (*this);
}
bitset<_Bits>& reset(size_t _Pos)
{ // set bit at _Pos to false
return (set(_Pos, false));
}
bitset<_Bits> operator~() const
{ // flip all bits
return (bitset<_Bits>(*this).flip());
}
bitset<_Bits>& flip()
{ // flip all bits
for (int _Wpos = _Words; 0 <= _Wpos; --_Wpos)
_Array[_Wpos] = (_Ty)~_Array[_Wpos];
_Trim();
return (*this);
}
bitset<_Bits>& flip(size_t _Pos)
{ // flip bit at _Pos
if (_Bits <= _Pos)
_Xran(); // _Pos off end
_Array[_Pos / _Bitsperword] ^= (_Ty)1 << _Pos % _Bitsperword;
return (*this);
}
unsigned long to_ulong() const
{ // convert bitset to unsigned long
enum
{ // cause zero divide if unsigned long not multiple of _Ty
_Assertion = 1
/ (int)(sizeof (unsigned long) % sizeof (_Ty) == 0)};
int _Wpos = _Words;
#pragma warning(push)
#pragma warning(disable: 6295)
for (; sizeof (unsigned long) / sizeof (_Ty) <= _Wpos; --_Wpos)
if (_Array[_Wpos] != 0)
_Xoflo(); // fail if any high-order words are nonzero
#pragma warning(pop)
unsigned long _Val = _Array[_Wpos];
for (; 0 <= --_Wpos; )
_Val = ((_Val << (_Bitsperword - 1)) << 1) | _Array[_Wpos];
return (_Val);
}
template
class _Alloc>
basic_string<_Elem, _Tr, _Alloc>
to_string(_Elem _E0 = (_Elem)'0') const
{ // convert bitset to string
basic_string<_Elem, _Tr, _Alloc> _Str;
typename basic_string<_Elem, _Tr, _Alloc>::size_type _Pos;
_Str.reserve(_Bits);
for (_Pos = _Bits; 0 < _Pos; )
_Str += (_Elem)(_E0 + (int)test(--_Pos));
return (_Str);
}
template
basic_string<_Elem, _Tr, allocator<_Elem> >
to_string(_Elem _E0 = (_Elem)'0') const
{ // convert bitset to string
return (to_string<_Elem, _Tr, allocator<_Elem> >(_E0));
}
template
basic_string<_Elem, char_traits<_Elem>, allocator<_Elem> >
to_string(_Elem _E0 = (_Elem)'0') const
{ // convert bitset to string
return (to_string<_Elem, char_traits<_Elem>,
allocator<_Elem> >(_E0));
}
string to_string(char _E0 = (char)'0') const
{ // convert bitset to string
return (to_string
}
size_t count() const
{ // count number of set bits
static char _Bitsperhex[] = "\0\1\1\2\1\2\2\3\1\2\2\3\2\3\3\4";
size_t _Val = 0;
for (int _Wpos = _Words; 0 <= _Wpos; --_Wpos)
for (_Ty _Wordval = _Array[_Wpos]; _Wordval != 0; _Wordval >>= 4)
_Val += _Bitsperhex[_Wordval & 0xF];
return (_Val);
}
size_t size() const
{ // return size of bitset
return (_Bits);
}
bool operator==(const bitset<_Bits>& _Right) const
{ // test for bitset equality
for (int _Wpos = _Words; 0 <= _Wpos; --_Wpos)
if (_Array[_Wpos] != _Right._Getword(_Wpos))
return (false);
return (true);
}
bool operator!=(const bitset<_Bits>& _Right) const
{ // test for bitset inequality
return (!(*this == _Right));
}
bool test(size_t _Pos) const
{ // test if bit at _Pos is set
if (_Bits <= _Pos)
_Xran(); // _Pos off end
return ((_Array[_Pos / _Bitsperword]
& ((_Ty)1 << _Pos % _Bitsperword)) != 0);
}
bool any() const
{ // test if any bits are set
for (int _Wpos = _Words; 0 <= _Wpos; --_Wpos)
if (_Array[_Wpos] != 0)
return (true);
return (false);
}
bool none() const
{ // test if no bits are set
return (!any());
}
bitset<_Bits> operator<<(size_t _Pos) const
{ // return bitset shifted left by _Pos
return (bitset<_Bits>(*this) <<= _Pos);
}
bitset<_Bits> operator>>(size_t _Pos) const
{ // return bitset shifted right by _Pos
return (bitset<_Bits>(*this) >>= _Pos);
}
_Ty _Getword(size_t _Wpos) const
{ // get word at _Wpos
return (_Array[_Wpos]);
}
private:
enum
{ // parameters for packing bits into words
_Bitsperword = CHAR_BIT * sizeof (_Ty), // bits in each word
_Words = _Bits == 0
? 0 : (_Bits - 1) / _Bitsperword}; // NB: number of words - 1
void _Tidy(_Ty _Wordval = 0)
{ // set all words to _Wordval
for (int _Wpos = _Words; 0 <= _Wpos; --_Wpos)
_Array[_Wpos] = _Wordval;
if (_Wordval != 0)
_Trim();
}
void _Trim()
{ // clear any trailing bits in last word
if (_Bits % _Bitsperword != 0)
_Array[_Words] &= ((_Ty)1 << _Bits % _Bitsperword) - 1;
}
void _Xinv() const
{ // report invalid string element in bitset conversion
_THROW(invalid_argument, "invalid bitset
}
void _Xoflo() const
{ // report converted value too big to represent
_THROW(overflow_error, "bitset
}
void _Xran() const
{ // report bit index out of range
_THROW(out_of_range, "invalid bitset
}
_Ty _Array[_Words + 1]; // the set of bits
};
全部回答
- 1楼网友:陪我到地狱流浪
- 2021-02-10 22:25
可以私聊我~
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯