std::bitset::operator[]
Aus cppreference.com
|
|
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
<metanoindex/>
<tbody> </tbody> bool operator[]( std::size_t pos ) const; constexpr bool operator[]( std::size_t pos ) const; |
(1) | (bis C + +11) (seit C++11) |
reference operator[]( std::size_t pos ); |
(2) | |
Greift auf das Bit an Position
pos. Die erste Version gibt den Wert des Bits, gibt die zweite Version ein Objekt vom Typ std::bitset::reference die Änderung des Wertes ermöglicht .Original:
Accesses the bit at position
pos. The first version returns the value of the bit, the second version returns an object of type std::bitset::reference that allows modification of the value.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Im Gegensatz zu
test(), nicht werfen Ausnahmen: das Verhalten ist undefiniert, wenn pos außerhalb der Grenzen .Original:
Unlike
test(), does not throw exceptions: the behavior is undefined if pos is out of bounds.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Parameter
| pos | - | Position des Bits, um zurückzukehren
Original: position of the bit to return The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
Rückgabewert
1)
der Wert des angeforderten Bits
Original:
the value of the requested bit
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
2)
ein Objekt vom Typ std::bitset::reference, die schriftlich an den angeforderten Bit erlaubt .
Original:
an object of type std::bitset::reference, which allows writing to the requested bit.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Ausnahmen
Keine
Original:
None
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Beispiel
#include <iostream>
#include <bitset>
int main()
{
std::bitset<8> b1(42);
for (std::size_t i = 0; i < b1.size(); ++i) {
std::cout << "b1[" << i << "]: " << b1[i] << '\n';
}
b1[0] = true; // modifies the first bit through bitset::refence
std::cout << "After setting bit 0, the bitset holds " << b1 << '\n';
}
Output:
b1[0]: 0
b1[1]: 1
b1[2]: 0
b1[3]: 1
b1[4]: 0
b1[5]: 1
b1[6]: 0
b1[7]: 0
After setting bit 0, bitset is 00101011
Siehe auch
greift bestimmtes Bit Original: accesses specific bit The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (öffentliche Elementfunktion) | |