Espacios de nombres
Variantes
Acciones

std::vector<bool>::flip

De cppreference.com
 
 
 
std::vector<bool>
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.
Los iteradores
Original:
Iterators
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.
std::vector<bool> specific
vector<bool>::flip
vector<bool>::swap
 
Definido en el archivo de encabezado <vector>
void flip();
(hasta C++20)
constexpr void flip();
(desde C++20)

Alterna cada bool en el vector (lo reemplaza con su valor opuesto).

Contenido

[editar] Parámetros

(Ninguno)

[editar] Valor de retorno

(Ninguno)

[editar] Ejemplo

#include <iostream>
#include <vector>
 
void imprimir(const std::vector<bool>& vb) {
    for (const bool b : vb)
        std::cout << b;
    std::cout << '\n';
}
 
int main() {
    std::vector<bool> v{0, 1, 0, 1};
    imprimir(v);
    v.flip();
    imprimir(v);
}

Salida:

0101
1010

[editar] Véase también

Accede el elemento especificado.
(función miembro pública de std::vector<T,Allocator>) [editar]
Alterna entre los valores de los bits
(función miembro pública de std::bitset) [editar]