std::bitset::test
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 test( size_t pos ) const; |
||
Gibt den Wert des Bits an der Position
pos .Original:
Returns the value of the bit at the position
pos.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
operator[](), führt eine Grenzüberprüfungsfehler und wirft std::out_of_range wenn pos nicht auf eine gültige Position in der bitset entsprechen .Original:
Unlike
operator[](), performs a bounds check and throws std::out_of_range if pos does not correspond to a valid position in the bitset.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
true wenn das angeforderte Bit gesetzt ist, false sonst .Original:
true if the requested bit is set, false otherwise.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
std::out_of_range wenn
pos nicht auf eine gültige Position innerhalb der bitset entsprechen .Original:
std::out_of_range if
pos does not correspond to a valid position within the bitset.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<10> b1("1111010000");
size_t idx = 0;
while (idx < b1.size() && !b1.test(idx)) {
++idx;
}
if (idx < b1.size()) {
std::cout << "first set bit at index " << idx << '\n';
} else {
std::cout << "no set bits\n";
}
return 0;
}
Output:
first set bit at index 4
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) | |