std::vector<bool,Allocator>::swap (3) - Linux Manuals
std::vector<bool,Allocator>::swap: std::vector<bool,Allocator>::swap
Command to display std::vector<bool,Allocator>::swap
manual in Linux: $ man 3 std::vector<bool,Allocator>::swap
NAME
std::vector<bool,Allocator>::swap - std::vector<bool,Allocator>::swap
Synopsis
Defined in header <vector>
static void swap(reference x, reference y);
Swaps the contents of x and y.
Parameters
x - std::vector<bool>::reference value to swap with y
y - std::vector<bool>::reference value to swap with x
Return value
(none)
Complexity
Constant.
Example
// Run this code
#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 << " "; }
}
Output:
1 0
0 1
See also
proxy class representing a reference to a single bool
reference (class)
swaps the contents
swap (public member function of std::vector<T,Allocator>)
specializes the std::swap algorithm
std::swap(std::vector) (function template)
Pages related to std::vector<bool,Allocator>::swap
- std::vector<bool,Allocator>::flip (3) - std::vector<bool,Allocator>::flip
- std::vector<bool> (3) - std::vector<bool>
- std::vector<bool>::reference (3) - std::vector<bool>::reference
- std::vector<T,Allocator>::assign (3) - std::vector<T,Allocator>::assign
- std::vector<T,Allocator>::at (3) - std::vector<T,Allocator>::at
- std::vector<T,Allocator>::back (3) - std::vector<T,Allocator>::back
- std::vector<T,Allocator>::begin,std::vector<T,Allocator>::cbegin (3) - std::vector<T,Allocator>::begin,std::vector<T,Allocator>::cbegin
- std::vector<T,Allocator>::capacity (3) - std::vector<T,Allocator>::capacity
- std::vector<T,Allocator>::clear (3) - std::vector<T,Allocator>::clear
- std::vector<T,Allocator>::data (3) - std::vector<T,Allocator>::data
- std::vector<T,Allocator>::emplace (3) - std::vector<T,Allocator>::emplace
- std::vector<T,Allocator>::emplace_back (3) - std::vector<T,Allocator>::emplace_back
- std::vector<T,Allocator>::empty (3) - std::vector<T,Allocator>::empty
- std::vector<T,Allocator>::end,std::vector<T,Allocator>::cend (3) - std::vector<T,Allocator>::end,std::vector<T,Allocator>::cend
- std::vector<T,Allocator>::erase (3) - std::vector<T,Allocator>::erase
- std::vector<T,Allocator>::front (3) - std::vector<T,Allocator>::front