Compare sets with '==' operator : set compare « set multiset « C++ Tutorial






#include <set>
#include <iostream>
#include <string>

using namespace std;

template <class T>
void print(T& c){
   for( typename T::iterator i = c.begin(); i != c.end(); i++ ){
      std::cout << *i << endl;
   }
}

int main()
{
  set<string> first;

  first.insert("r");
  first.insert("T");
  first.insert("s");

  cout << first.size() << endl;

  set<string> second (first);   // Copy constructor

  second.insert("r");
  second.insert("K");
  second.insert("S");
  second.insert("b");

  cout << second.size() << endl;

  // Are the sets the same?
  if (first == second)
    cout << "Sets have same elements\n";
  else
    cout << "Not same elements\n";

}








19.4.set compare
19.4.1.Compare sets with '==' operator
19.4.2.set comparison