Espaces de noms
Variantes
Affichages
Actions

std::bitset::test

De cppreference.com
< cpp‎ | utility‎ | bitset

 
 
 
std::bitset
Types de membres
Original:
Member types
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
bitset::reference
Les fonctions membres
Original:
Member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
bitset::bitset
bitset::operator==
bitset::operator!=
Elément d'accès
Original:
Element access
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
bitset::operator[]
bitset::test
bitset::all
bitset::any
bitset::none
(C++11)

 
bitset::count
Capacité
Original:
Capacity
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
bitset::size
Modificateurs
Original:
Modifiers
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
bitset::operator&=
bitset::operator|=
bitset::operator^=
bitset::operator~
bitset::operator<<=
bitset::operator>>=
bitset::operator<<
bitset::operator>>
bitset::set
bitset::reset
bitset::flip
Conversions
Original:
Conversions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
bitset::to_string
bitset::to_ulong
bitset::to_ullong (C++11)
Tiers fonctions
Original:
Non-member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
operator&
operator|
operator^
operator<<
operator>>
Classes d'aide
Original:
Helper classes
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
std::hash (C++11)
 
bool test( size_t pos ) const;
Retourne la valeur du bit à la 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.
Contrairement operator[](), effectue un contrôle de limites et jette std::out_of_range si pos ne correspond pas à une position valable dans la bitset .
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.

Sommaire

[modifier] Paramètres

pos -
position du bit de revenir
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.

[modifier] Retourne la valeur

true si le bit demandé est réglé, false autrement .
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.

[modifier] Exceptions

std::out_of_range si pos ne correspond pas à une position valable dans le bitset .
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.

[modifier] Exemple

#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;
}

Résultat :

first set bit at index 4

[modifier] Voir aussi

accède bit spécifique
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.

(fonction membre publique) [edit]