std::vector<bool,Allocator>::flip
From cppreference.com
 
 
 < cpp | container | vector bool 
 
 
 C++ 
 Feature test macros (C++20)
 Concepts library (C++20)
 Metaprogramming library (C++11)
 Ranges library (C++20)
 Filesystem library (C++17)
 Concurrency support library (C++11)
 Execution control library (C++26)
Containers library 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
(C++17)
(C++11)
(C++26)
(C++26)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++23)
(C++23)
(C++23)
(C++23)
(C++20)
(C++23)
 Tables
std::vector<bool> 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
(C++23)
(C++11)
(C++11)
(C++11)
(C++11)
(DR*)
(C++23)
(C++23)
(C++11)
(C++11)
vector<bool>::flip
(C++20)
(C++20)(C++20)
  (until C++20)(until C++20)(until C++20)(until C++20)(until C++20)
(C++11)
 Deduction guides (C++17)
Defined in header 
 
 
<vector> 
 void flip();
 
 (constexpr since C++20)
Toggles each bool (replaces with its opposite value) in the vector.
[edit] Example
Run this code
#include <iostream> #include <vector> void print(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}; print(v); v.flip(); print(v); }
Output:
0101 1010