std::vector<bool,Allocator>:: flip
From cppreference.net
<
cpp
|
container
|
vector bool
C++
Containers library
|
(C++17)
|
||||
| Sequence | ||||
|
(C++11)
|
||||
|
(C++26)
|
||||
|
(C++26)
|
||||
|
(C++11)
|
||||
| Associative | ||||
| Unordered associative | ||||
|
(C++11)
|
||||
|
(C++11)
|
||||
|
(C++11)
|
||||
|
(C++11)
|
||||
| Adaptors | ||||
|
(C++23)
|
||||
|
(C++23)
|
||||
|
(C++23)
|
||||
|
(C++23)
|
||||
| Views | ||||
|
(C++20)
|
||||
|
(C++23)
|
||||
| Tables | ||||
| Iterator invalidation | ||||
| Member function table | ||||
| Non-member function table |
std::vector<bool>
| Member types | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Member functions | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Non-member functions | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Helper classes | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
(C++11)
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Deduction guides (C++17) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
ヘッダーで定義
<vector>
|
||
|
void
flip
(
)
;
|
(constexpr since C++20) | |
各 bool を切り替え(反対の値で置き換え) vector 内で実行します。
例
このコードを実行
#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); }
出力:
0101 1010
関連項目
|
指定された要素にアクセスする
(
std::vector<T,Allocator>
の公開メンバ関数)
|
|
|
ビットの値を反転する
(
std::bitset<N>
の公開メンバ関数)
|