Freigeben über


operator!= (set)

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

bool operator!=(
   const set <Key, Traits, Allocator>& _Left,
   const set <Key, Traits, Allocator>& _Right
);

Parameters

  • _Left
    An object of type set.

  • _Right
    An object of type set.

Return Value

true if the sets are not equal; false if sets are equal.

Remarks

The comparison between set objects is based on a pairwise comparison between their elements. Two sets are equal if they have the same number of elements and their respective elements have the same values. Otherwise, they are unequal.

Example

// set_op_ne.cpp
// compile with: /EHsc
#include <set>
#include <iostream>

int main( )
{
   using namespace std;
   set <int> s1, s2, s3;
   int i;

   for ( i = 0 ; i < 3 ; i++ )
   {
      s1.insert ( i );
      s2.insert ( i * i );
      s3.insert ( i );
   }

   if ( s1 != s2 )
      cout << "The sets s1 and s2 are not equal." << endl;
   else
      cout << "The sets s1 and s2 are equal." << endl;

   if ( s1 != s3 )
      cout << "The sets s1 and s3 are not equal." << endl;
   else
      cout << "The sets s1 and s3 are equal." << endl;
}
The sets s1 and s2 are not equal.
The sets s1 and s3 are equal.

Requirements

Header: <set>

Namespace: std

See Also

Reference

Standard Template Library

Other Resources

<set> Members