BDE 4.14.0 Production release
|
#include <bslstl_bitset.h>
Classes | |
class | reference |
Public Member Functions | |
BSLS_KEYWORD_CONSTEXPR | bitset () BSLS_KEYWORD_NOEXCEPT |
Create a bitset with all bits initialized to 0 . | |
BSLS_KEYWORD_CONSTEXPR | bitset (unsigned long long val) BSLS_KEYWORD_NOEXCEPT |
template<class CHAR_TYPE , class TRAITS , class ALLOCATOR > | |
bitset (const std::basic_string< CHAR_TYPE, TRAITS, ALLOCATOR > &str, typename std::basic_string< CHAR_TYPE, TRAITS, ALLOCATOR >::size_type pos=0, typename std::basic_string< CHAR_TYPE, TRAITS, ALLOCATOR >::size_type n=std::basic_string< CHAR_TYPE, TRAITS, ALLOCATOR >::npos, CHAR_TYPE zeroChar=CHAR_TYPE('0'), CHAR_TYPE oneChar=CHAR_TYPE('1')) | |
template<class CHAR_TYPE , class TRAITS , class ALLOCATOR > | |
bitset (const bsl::basic_string< CHAR_TYPE, TRAITS, ALLOCATOR > &str, typename bsl::basic_string< CHAR_TYPE, TRAITS, ALLOCATOR >::size_type pos=0, typename bsl::basic_string< CHAR_TYPE, TRAITS, ALLOCATOR >::size_type n=bsl::basic_string< CHAR_TYPE, TRAITS, ALLOCATOR >::npos, CHAR_TYPE zeroChar=CHAR_TYPE('0'), CHAR_TYPE oneChar=CHAR_TYPE('1')) | |
bitset & | operator&= (const bitset &rhs) BSLS_KEYWORD_NOEXCEPT |
bitset & | operator|= (const bitset &rhs) BSLS_KEYWORD_NOEXCEPT |
bitset & | operator^= (const bitset &rhs) BSLS_KEYWORD_NOEXCEPT |
bitset & | operator<<= (std::size_t pos) BSLS_KEYWORD_NOEXCEPT |
bitset & | operator>>= (std::size_t pos) BSLS_KEYWORD_NOEXCEPT |
bitset & | flip () BSLS_KEYWORD_NOEXCEPT |
bitset & | flip (std::size_t pos) |
bitset & | reset () BSLS_KEYWORD_NOEXCEPT |
bitset & | reset (std::size_t pos) |
bitset & | set () BSLS_KEYWORD_NOEXCEPT |
bitset & | set (std::size_t pos, int val=true) |
reference | operator[] (std::size_t pos) |
bitset | operator<< (std::size_t pos) const BSLS_KEYWORD_NOEXCEPT |
bitset | operator>> (std::size_t pos) const BSLS_KEYWORD_NOEXCEPT |
bitset | operator~ () const BSLS_KEYWORD_NOEXCEPT |
BSLS_KEYWORD_CONSTEXPR bool | operator[] (std::size_t pos) const |
Return the value of the bit position at the specified pos . | |
bool | operator== (const bitset &rhs) const BSLS_KEYWORD_NOEXCEPT |
bool | operator!= (const bitset &rhs) const BSLS_KEYWORD_NOEXCEPT |
bool | all () const BSLS_KEYWORD_NOEXCEPT |
bool | any () const BSLS_KEYWORD_NOEXCEPT |
bool | none () const BSLS_KEYWORD_NOEXCEPT |
std::size_t | count () const BSLS_KEYWORD_NOEXCEPT |
Return the number of bits in this bitset that have the value of 1. | |
BSLS_KEYWORD_CONSTEXPR std::size_t | size () const BSLS_KEYWORD_NOEXCEPT |
Return the number of bits this bitset holds. | |
bool | test (size_t pos) const |
template<class CHAR_TYPE , class TRAITS , class ALLOCATOR > | |
basic_string< CHAR_TYPE, TRAITS, ALLOCATOR > | to_string (CHAR_TYPE zero=CHAR_TYPE('0'), CHAR_TYPE one=CHAR_TYPE('1')) const |
unsigned long | to_ulong () const |
Friends | |
class | reference |
This class template provides an STL-compliant bitset
. For the requirements of a bitset
class, consult the second revision of the ISO/IEC 14882 Programming Language c++ (2011).
In addition to the methods defined in the standard, this class also provides an extra constructor that takes a bsl::basic_string
. This extra constructor provides the capability to construct a bitset
from a bsl::basic_string
, in addition to a std::basic_string
.
|
inline |
BSLS_KEYWORD_CONSTEXPR bsl::bitset< N >::bitset | ( | unsigned long long | val | ) |
Create a bitset with its first M
bit positions correspond to bit values in the specified val
. M
is the smaller of the parameterized N
and 8 * sizeof(unsigned long long)
. If M < N
, the remaining bit positions are initialized to 0.
|
inlineexplicit |
Create a bitset with its first M
bit positions corresponding to the characters in the specified pos
of the specified str
. M
is the smaller of the parameterized N
and str.length()
. If M < N
, the remaining bit positions are initialized to 0. Characters with the value zeroChar
correspond to an unset bit and characters with the value oneChar
correspond to a set bit. The behavior is undefined if any characters in str
is neither the specified zeroChar
nor the specified oneChar
.
|
inlineexplicit |
Create a bitset with its first M
bit positions corresponding to 0 the characters in the specified pos
of the specified str
. M
is the smaller of the parameterized N
and str.length()
. If M < N
, the remaining bit positions are initialized to 0. Characters with the value zeroChar
correspond to an unset bit and characters with the value oneChar
correspond to a set bit. The behavior is undefined if the characters in the specified str
is not the specified zeroChar
and not the specified oneChar
bool bsl::bitset< N >::all | ( | ) | const |
bool bsl::bitset< N >::any | ( | ) | const |
Return true
if one or more of the bits in this bitset has the value of 1 and false
otherwise.
std::size_t bsl::bitset< N >::count | ( | ) | const |
bitset< N > & bsl::bitset< N >::flip | ( | ) |
Toggle all bits of this bitset and return a reference to this modifiable bitset.
|
inline |
Toggle the bit at the specified pos
of this bitset and return a reference to this modifiable bitset.
|
inline |
|
inline |
Return true
if the specified rhs
do not have the same value as this bitset and false
otherwise. Two bitset do not have the same value when either the sequence or the value of bits they hold are not the same.
bitset< N > & bsl::bitset< N >::operator&= | ( | const bitset< N > & | rhs | ) |
Clear each bit of this bitset for each corresponding bit that is 0 in the specified rhs
, and leaves all other bits unchanged. Return a reference to this modifiable bitset. Note that this is equivalent to a bitwise OR.
|
inline |
Return a bitset constructed from shifting this bitset left by the specified pos
.
bitset< N > & bsl::bitset< N >::operator<<= | ( | std::size_t | pos | ) |
Shift the bits of this bitset left (towards the most significant bit) by the specified pos
and return a reference to this modifiable bitset. For all bits with position I where I <= pos
, the new value is 0. The behavior is undefined unless pos <= N
.
|
inline |
Return true
if the specified rhs
has the same value as this bitset and false
otherwise. Two bitsets have the same value when the sequence and value of bits they hold are the same.
|
inline |
Return a bitset constructed from shifting this bitset right by the specified pos
.
bitset< N > & bsl::bitset< N >::operator>>= | ( | std::size_t | pos | ) |
Shift the bits of this bitset right (towards the least significant bit) by the specified pos
and return a reference to this modifiable bitset. For all bits with position I where I > N - pos
, the new value is 0. The behavior is undefined unless pos <= N
.
|
inline |
Return a reference
to the modifiable bit position at the specified pos
.
|
inline |
bitset< N > & bsl::bitset< N >::operator^= | ( | const bitset< N > & | rhs | ) |
Toggle each bit of this bitset for each corresponding bit that is 1 in the specified rhs
, and leaves all other bits unchanged. Return a reference to this modifiable bitset. Note that this is equivalent to a bitwise XOR.
bitset< N > & bsl::bitset< N >::operator|= | ( | const bitset< N > & | rhs | ) |
Set each bit of this bitset for each corresponding bit that is 1 in the specified rhs
, and leaves all other bits unchanged. Return a reference to this modifiable bitset. Note that this is equivalent to a bitwise AND.
|
inline |
Toggle all bits of this bitset and return a reference to this modifiable bitset.
|
inline |
Set all bits of this bitset to 0 and return a reference to this modifiable bitset.
|
inline |
Set the bit at the specified pos
of this bitset to 0 and return a reference to this modifiable bitset.
|
inline |
Set all bits of this bitset to 1 and return a reference to this modifiable bitset.
bitset< N > & bsl::bitset< N >::set | ( | std::size_t | pos, |
int | val = true |
||
) |
Set the bit at the specified pos
of this bitset to 1 and return a reference to this modifiable bitset. Optionally specify val
as the value to set the bit. If val
is non-zero, the bit is set to 1, otherwise the bit is set to 0.
|
inline |
|
inline |
Return true
if the bit at the specified pos
has the value of 1 and false
otherwise.
basic_string< CHAR_TYPE, TRAITS, ALLOCATOR > bsl::bitset< N >::to_string | ( | CHAR_TYPE | zero = CHAR_TYPE('0') , |
CHAR_TYPE | one = CHAR_TYPE('1') |
||
) | const |
unsigned long bsl::bitset< N >::to_ulong | ( | ) | const |
Return an unsigned
long
value that has the same bit value as the bitset. Note that the behavior is undefined if the bitset cannot be represented as an unsigned
long
.
|
friend |