Namespaces
Variants

std::vector<bool,Allocator>:: flip

From cppreference.net
헤더 파일에 정의됨 <vector>
void flip ( ) ;
(C++20부터 constexpr)

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> 의 public member function)
비트 값 전환
( std::bitset<N> 의 public member function)