Udostępnij za pośrednictwem


vector<bool>::swap

Wymiany elementów dwa wektory z elementów logicznych.

void swap(
    vector<bool>& _Right
);
static void swap(
    reference _Left,
    reference _Right
);

Parametry

  • _Left
    Vector, której elementy są wymieniane z tymi wektor _Right.

  • _Right
    Vector, której elementy są wymieniane z tymi wektor _Left.

Przykład

// 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;
}
  

Wymagania

Nagłówek: <vector>

Obszar nazw: std

Zobacz też

Informacje

vector Class

Standardowa biblioteka szablonu