vector<bool>::swap
두 벡터의 요소를 부울 요소와 교환합니다.
void swap(
vector<bool>& _Right
);
static void swap(
reference _Left,
reference _Right
);
매개 변수
_Left
요소가 되는 벡터와 교환할 벡터 _Right._Right
요소가 되는 벡터와 교환할 벡터 _Left.
예제
// vector_bool_swap.cpp
// compile with: /EHsc
#include <vector>
#include <iostream>
int main( )
{
using namespace std;
_Bvector v1, v2;
v1.push_back( 1 );
v1.push_back( 1 );
v2.push_back( 0 );
v2.push_back( 0 );
cout << "The vector v1 is: " << v1.front( ) << " " << v1.back( ) << endl;
cout << "The vector v2 is: " << v2.front( ) << " " << v2.back( ) << endl;
swap( v1,v2 );
cout << "After swapping, vector v1 is: " << v1.front( ) << " " << v1.back( ) << endl;
cout << "After swapping, vector v2 is: " << v2.front( ) << " " << v2.back( ) << endl;
}
요구 사항
헤더: <vector>
네임 스페이스: std