operator== (<vector>)

Tests if the object on the left side of the operator is equal to the object on the right side.

bool operator==( 
   const vector<Type, Allocator>& _Left, 
   const vector<Type, Allocator>& _Right 
);

Parameters

  • _Left
    An object of type vector.

  • _Right
    An object of type vector.

Return Value

true if the vector on the left side of the operator is equal to the vector on the right side of the operator; otherwise false.

Remarks

Two vectors are equal if they have the same number of elements and their respective elements have the same values. Otherwise, they are unequal.

Example

// vector_op_eq.cpp
// compile with: /EHsc
#include <vector>
#include <iostream>

int main( )
{
   using namespace std; 
   
   vector <int> v1, v2;
   v1.push_back( 1 );
   v2.push_back( 1 );

   if ( v1 == v2 )
      cout << "Vectors equal." << endl;
   else
      cout << "Vectors not equal." << endl;
}

Vectors equal.

Requirements

Header: <vector>

Namespace: std

See Also

Reference

vector::operator==

Standard Template Library

Other Resources

<vector> Members