val and all other bits, if any, to zero. template<class Char, class Traits, class Alloc> explicit bitset(const basic_string<Char,Traits,Alloc>& s, size_t pos = 0, size_t n = basic_string<Char,Traits,Alloc>::npos) Conversion from string. Constructs a bitset, initializing the first M bits to the corresponding characters in s, where M is defined as min(N, min(s.size() – pos, n)). Note that the highest character position in s, not the lowest, corresponds to the least significant bit. That is, character position pos + M – 1 – i corresponds to bit i. So, for example, bitset(string('1101')) is the same as bitset(13ul). This function throws out_of_range if pos > s.size(), and invalid_argument if any of the characters used to initialize the bits are anything other than 0 or 1. bitset& operator&=(const bitset&) Bitwise and. bitset& operator|=(const bitset&) Bitwise inclusive or. bitset& operator^=(const bitset&) Bitwise exclusive or. bitset& operator<<=(size_t n) Left shift, where bit 0 is considered the least significant bit. Bit i takes on the previous value of bit i – n, or zero if no such bit exists. bitset& operator>>=(size_t n) Right shift, where bit 0 is considered the least significant bit. Bit i takes on the previous value of bit i + n, or zero if no such bit exists. bitset operator<<(size_t n) const Returns a copy of *this shifted left by n bits. Note that the expression b << n is equivalent to constructing a temporary copy of b and then using operator<<=. bitset operator>>(size_t n) const Returns a copy of *this shifted right by n bits. Note that the expression b >> n is equivalent to constructing a temporary copy of b and then using operator>>=. bitset& set() Sets every bit. bitset& flip() Flips the value of every bit. bitset operator~() const Returns a copy of *this with all of its bits flipped. bitset& reset() Clears every bit. bitset& set(size_t n, int val = 1) Sets bit n if val is nonzero, and clears bit n if val is zero. Throws out_of_range if n >= N. bitset& reset(size_t n) Clears bit n. Throws out_of_range if n >= N. bitset flip(size_t n) Flips bit n. Throws out_of_range if n >= N. size_t size() const Returns N. size_t count() const Returns the number of bits that are set. bool any() const Returns true if any bits are set.
Добавить отзыв
ВСЕ ОТЗЫВЫ О КНИГЕ В ИЗБРАННОЕ

0

Вы можете отметить интересные вам фрагменты текста, которые будут доступны по уникальной ссылке в адресной строке браузера.

Отметить Добавить цитату