The template argument, Nb, may be any non-negative number, specifying the number of bits (e.g., "0", "12", "1024*1024").
In the general unoptimized case, storage is allocated in word-sized blocks. Let B be the number of bits in a word, then (Nb+(B-1))/B words will be used for storage. B - NbB bits are unused. (They are the high-order bits in the highest word.) It is a class invariant that those unused bits are always zero.
If you think of bitset as "a simple array of bits," be aware that your mental picture is reversed: a bitset behaves the same way as bits in integers do, with the bit at index 0 in the "least significant / right-hand" position, and the bit at index Nb-1 in the "most significant / left-hand" position. Thus, unlike other containers, a bitset's index "counts from right to left," to put it very loosely.
This behavior is preserved when translating to and from strings. For example, the first line of the following program probably prints "b('a') is 0001100001" on a modern ASCII system.
#include <bitset> #include <iostream> #include <sstream> using namespace std; int main() { long a = 'a'; bitset<10> b(a); cout << "b('a') is " << b << endl; ostringstream s; s << b; string str = s.str(); cout << "index 3 in the string is " << str[3] << " but\n" << "index 3 in the bitset is " << b[3] << endl; }
Also see http://gcc.gnu.org/onlinedocs/libstdc++/ext/sgiexts.html#ch23 for a description of extensions.
Definition at line 646 of file bitset.
|
All bits set to zero.
Reimplemented in std::__debug::bitset< _Nb >. |
|
Initial bits bitwise-copied from a single word (others set to zero).
Reimplemented in std::__debug::bitset< _Nb >. |
|
Use a subset of a string.
Definition at line 755 of file bitset. References __N, std::bitset< _Nb >::_M_copy_from_string(), and std::basic_string< _CharT, _Traits, _Alloc >::size(). |
|
Use a subset of a string.
Definition at line 776 of file bitset. References __N, std::bitset< _Nb >::_M_copy_from_string(), and std::basic_string< _CharT, _Traits, _Alloc >::size(). |
|
Tests whether any of the bits are on.
|
|
Returns the number of bits which are set.
|
|
Toggles a given bit to its opposite value.
Reimplemented in std::__debug::bitset< _Nb >. Definition at line 961 of file bitset. References __N, and std::bitset< _Nb >::_Unchecked_flip(). |
|
Toggles every bit to its opposite value.
Reimplemented in std::__debug::bitset< _Nb >. Definition at line 948 of file bitset. Referenced by std::__debug::bitset< _Nb >::flip(). |
|
Tests whether any of the bits are on.
|
|
Operations on bitsets.
Reimplemented in std::__debug::bitset< _Nb >. |
|
Self-explanatory.
Reimplemented in std::__debug::bitset< _Nb >. |
|
Operations on bitsets.
Reimplemented in std::__debug::bitset< _Nb >. Definition at line 824 of file bitset. References std::_Base_bitset<((_Nb)< 1?0:((_Nb)+numeric_limits< unsigned long >::digits-1)/numeric_limits< unsigned long >::digits)>::_M_do_left_shift(), and std::_Base_bitset<((_Nb)< 1?0:((_Nb)+numeric_limits< unsigned long >::digits-1)/numeric_limits< unsigned long >::digits)>::_M_do_reset(). |
|
These comparisons for equality/inequality are, well, bitwise.
Reimplemented in std::__debug::bitset< _Nb >. |
|
Self-explanatory.
Reimplemented in std::__debug::bitset< _Nb >. |
|
Operations on bitsets.
Reimplemented in std::__debug::bitset< _Nb >. Definition at line 837 of file bitset. References std::_Base_bitset<((_Nb)< 1?0:((_Nb)+numeric_limits< unsigned long >::digits-1)/numeric_limits< unsigned long >::digits)>::_M_do_reset(), and std::_Base_bitset<((_Nb)< 1?0:((_Nb)+numeric_limits< unsigned long >::digits-1)/numeric_limits< unsigned long >::digits)>::_M_do_right_shift(). |
|
Array-indexing support.
Reimplemented in std::__debug::bitset< _Nb >. Definition at line 991 of file bitset. References std::bitset< _Nb >::reference. |
|
Operations on bitsets.
Reimplemented in std::__debug::bitset< _Nb >. |
|
Operations on bitsets.
Reimplemented in std::__debug::bitset< _Nb >. |
|
See the no-argument flip().
Reimplemented in std::__debug::bitset< _Nb >. |
|
Sets a given bit to false.
set(pos,false) .
Reimplemented in std::__debug::bitset< _Nb >. Definition at line 937 of file bitset. References __N, and std::bitset< _Nb >::_Unchecked_reset(). |
|
Sets every bit to false.
Reimplemented in std::__debug::bitset< _Nb >. Definition at line 923 of file bitset. Referenced by std::bitset< _Nb >::_M_copy_from_string(), and std::__debug::bitset< _Nb >::reset(). |
|
Sets a given bit to a particular value.
Reimplemented in std::__debug::bitset< _Nb >. Definition at line 912 of file bitset. References __N, and std::bitset< _Nb >::_Unchecked_set(). |
|
Sets every bit to true.
Reimplemented in std::__debug::bitset< _Nb >. Definition at line 898 of file bitset. Referenced by std::__debug::bitset< _Nb >::set(). |
|
Returns the total number of bits.
|
|
Tests the value of a bit.
Definition at line 1088 of file bitset. References __N, and std::bitset< _Nb >::_Unchecked_test(). |
|
Retuns a character interpretation of the bitset.
Reimplemented in std::__debug::bitset< _Nb >, std::__debug::bitset< _Nb >, std::__debug::bitset< _Nb >, and std::__debug::bitset< _Nb >. Definition at line 1019 of file bitset. References std::bitset< _Nb >::_M_copy_to_string(). |
|
Retuns a numerical interpretation of the bitset.
|