Espacios de nombres
Variantes

std::vector<bool>::swap

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
 
<tbody> </tbody> <tbody class="t-dcl-rev "> </tbody><tbody> </tbody>
Definido en el archivo de encabezado <vector>
static void swap(reference x, reference y);
(hasta C++20)
constexpr static void swap(reference x, reference y);
(desde C++20)

Intercambia el contenido de x yy.

Parámetros

x - Valor std::vector<bool>::reference a intercambiar con y.
y - Valor std::vector<bool>::reference a intercambiar con x.

Valor de retorno

(Ninguno)

Complejidad

Constante.

Ejemplo

#include <vector>
#include <iostream>

int main()
{
    std::vector<bool> vb1{ 1,0 };

    for (auto e : vb1) { std::cout << e << " "; }
    std::cout << '\n';

    vb1.swap(vb1[0], vb1[1]);

    for (auto e : vb1) { std::cout << e << " "; }
}

Salida:

1 0 
0 1

Véase también

Clase representante que representa una referencia a un solo bool.
(clase)
Intercambia el contenido.
(función miembro pública de std::vector<T,Allocator>) [editar]
Especializa el algoritmo std::swap.
(plantilla de función) [editar]