Hinweis
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, sich anzumelden oder das Verzeichnis zu wechseln.
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, das Verzeichnis zu wechseln.
Describes a type of object that stores a sequence consisting of a fixed number of bits that provide a compact way of keeping flags for a set of items or conditions. The bitset class supports operations on objects of type bitset that contain a collection of bits and provide constant-time access to each bit.
template <size_t N>
class bitset
Parameters
- N
Specifies the number of bits in the bitset object with a nonzero integer of type size_t that must be known at compile time.
Remarks
Unlike the similar vector<bool> Class, the bitset class does not have iterators and is not an Standard Template Library container. It also differs from vector<bool> by being of some specific size that is fixed at compile time in accordance with the size specified by the template parameter N when the bitset<N> is declared.
A bit is set if its value is 1 and reset if its value is 0. To flip or toggle a bit is to change its value from 1 to 0 or from 0 to 1. The N bits in a bitset are indexed by integer values from 0 to N - 1, where 0 indexes the first bit position and N* *- 1 the final bit position.
Constructors
Constructs an object of class bitset<N> and initializes the bits to zero, to some specified value, or to values obtained from characters in a string. |
Typedefs
A type that is a synonym for the data type bool and can be used to reference element bits in a bitset. |
Member Functions
Tests all of the bits in this bitset to determine whether they are all set to true. |
|
The member function tests whether any bit in the sequence is set to 1. |
|
The member function returns the number of bits set in the bit sequence. |
|
Toggles the value of all the bits in a bitset or toggles a single bit at a specified position. |
|
Tests if no bit has been set to 1 in a bitset object. |
|
Resets all the bits in a bitset to 0 or resets a bit at a specified position to 0. |
|
Sets all the bits in a bitset to 1 or sets a bit at a specified position to 1. |
|
Returns the number of bits in a bitset object. |
|
Tests whether the bit at a specified position in a bitset is set to 1. |
|
Converts a bitset object to a string representation. |
|
Returns the sum of the bit values in the bitset as an unsigned long long. |
|
Converts a bitset object to the unsigned long that would generate the sequence of bits contained if used to initialize the bitset. |
Member Classes
A proxy class that provides references to bits contained in a bitset that is used to access and manipulate the individual bits as a helper class for the operator[] of class bitset. |
Operators
Tests a target bitset for inequality with a specified bitset. |
|
Performs a bitwise combination of bitsets with the logical AND operation. |
|
Shifts the bits in a bitset to the left a specified number of positions and returns the result to a new bitset. |
|
Shifts the bits in a bitset to the left a specified number of positions and returns the result to the targeted bitset. |
|
Tests a target bitset for equality with a specified bitset. |
|
Shifts the bits in a bitset to the right a specified number of positions and returns the result to a new bitset. |
|
Shifts the bits in a bitset to the right a specified number of positions and returns the result to the targeted bitset. |
|
Returns a reference to a bit at a specified position in a bitset if the bitset is modifiable; otherwise, it returns the value of the bit at that position. |
|
Performs a bitwise combination of bitsets with the exclusive OR operation. |
|
Performs a bitwise combination of bitsets with the inclusive OR operation. |
|
Toggles all the bits in a target bitset and returns the result. |
Requirements
Header: <bitset>
Namespace: std