Espacios de nombres
Variantes

std::bitset::test

De cppreference.com
 
 
Biblioteca de servicios
 
std::bitset
Tipos de miembros
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.
Las funciones miembro
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.
Elemento acceso
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.
Capacidad
Original:
Capacity
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Modificadores
Original:
Modifiers
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Conversiones
Original:
Conversions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Terceros funciones
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.
Clases de ayuda
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.
(C++11)
 
<tbody> </tbody>
bool test( size_t pos ) const;
Devuelve el valor del bit en la posición 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.
A diferencia de operator[](), realiza una comprobación de límites y lanza std::out_of_range pos si no se corresponde con una posición válida en el 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.

Parámetros

pos -
posición del bit para volver
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.

Valor de retorno

true si el bit requerido se establece, por otra parte false .
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.

Excepciones

std::out_of_range pos si no se corresponde con una posición válida dentro de la 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.

Ejemplo

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

Salida:

first set bit at index 4

Ver también

acceso a un bit específico
(función miembro pública) [editar]