title: STABLE_PARTITION problems: no matching function to call to "swap"
body: <p>somehow I can't use stable_partition algorithm on </p>
  
  <pre><code>vector&lt;pair&lt;Class, string&gt;&gt;. 
  </code></pre>
  
  <p>I can re-organize the code to get what I want, but for me (as I am new to C++) it's more "WHY" and not "HOW" question. will be glad if you clarify this behavior:</p>
  
  <p>First, class Date (you can omit it and come look at it later):</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;vector&gt;
  #include &lt;algorithm&gt;
  #include &lt;set&gt;
  #include &lt;vector&gt;
  
  using namespace std;
  
  class Date {
  public:
      Date(int new_year, int new_month, int new_day) {
          year = new_year;    month = new_month;      day = new_day;
        }
  
      int GetYear() const {return year;}
      int GetMonth() const {return month;}
      int GetDay() const {return day;}
  
  private:
    int year, month, day;
  };
  
  bool operator&lt;(const Date&amp; lhs, const Date&amp; rhs) {
    return vector&lt;int&gt;{lhs.GetYear(), lhs.GetMonth(), lhs.GetDay()} &lt;
        vector&lt;int&gt;{rhs.GetYear(), rhs.GetMonth(), rhs.GetDay()};
  }
  
  bool operator==(const Date&amp; lhs, const Date&amp; rhs) {
    return vector&lt;int&gt;{lhs.GetYear(), lhs.GetMonth(), lhs.GetDay()} ==
        vector&lt;int&gt;{rhs.GetYear(), rhs.GetMonth(), rhs.GetDay()};
  }
  
  </code></pre>
  
  <p>SO THIS IS THE CLASS WITH THE TROUBLE:</p>
  
  <pre><code>class Database {
  public:
      void Add(const Date&amp; date, const string event){
              storage.push_back(make_pair(date, event));
              set_dates.insert(date);
  
      }
  
  
      void Print(ostream&amp; s) const{
  
          for(const auto&amp; date : set_dates) {
  // TROUBLE IS HERE:
              auto it = stable_partition(begin(storage), end(storage),
                  [date](const pair&lt;Date, string&gt; p){
                  return p.first == date;
              });
  
          };
  
  }
  
  private:
        vector&lt;pair&lt;Date, string&gt;&gt; storage;
        set&lt;Date&gt; set_dates;
  
  };
  </code></pre>
  
  <p>When compiled, it returns a lot of problems of same kind:
  <a href="https://i.stack.imgur.com/CyKto.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CyKto.jpg" alt="enter image description here"></a></p>
  
  <p>I've tried the same code on <code>vector&lt;pair&lt;int, string&gt;&gt;</code> (used stable_partition with lambda {return p.first == _int; } and it worked. </p>
  
  <p>Would appreciate your help</p>