title: no match for 'operator+' in sort in c++
body: <p>I have defined a class</p>
  
  <pre><code>class Rent
  {
      public:    
      int s_time, duration, price, e_time;
      Rent(int s, int d, int p)
      {
          s_time = s;
          duration = d;
          price = p;
          e_time = s + d;
      }
      bool operator&lt;(Rent const &amp;r1)
      {
          return e_time &lt; r1.e_time;
      }
  };
  </code></pre>
  
  <p>Wished to sort it on basis of <code>e_time</code>, so I have defined <code>&lt;</code> over <code>Rent</code>, however, I keep getting error</p>
  
  <pre><code>rent.cpp:38:12: error: no match for ‘operator+’ (operand types are ‘std::vector&lt;Rent&gt;’ and ‘int’)
  
       sort(R, R+n);
                ^
  </code></pre>
  
  <p>when I tried <code>sort(R, R+n);</code>. <code>R</code> is a vector of type <code>Rent</code> and <code>n</code> is integer(size of the vector).</p>
  
  <p>Besides the above, I tried these two ways but still failed!</p>
  
  <pre><code>sort(R, R + sizeof(R)/sizeof(R[0]));
  sort(R.begin(), R.end());
  </code></pre>
  
  <p>I googled and got some solutions with lambdas but again the second parameter to sort() is of type int + custom_datatype.</p>
  
  <p>Any help would be great.</p>