title: C++ - match and replace element by value in custom data type vector
body: <p>I have a vector which contains data for different groups. If I insert new data for a group into a vector it should replace the old data with a new one for the same group number. For this particular example <code>std::replace</code> gives an error <code>std::replace': no matching overloaded function found</code></p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;vector&gt;
  #include &lt;algorithm&gt;
  
  class data
  {
      public:
          int group;
          bool condition;
          int time;
          friend bool operator==(const data&amp; lhs, const data&amp; rhs);
          data(int g, bool c, int t) 
          {
              group = g;
              condition = c;
              time = t;
          }
  };
  
  bool  operator==(const data&amp; lhs, const data&amp; rhs)
  {
      return lhs.group == rhs.group;
  }
  int main(int argc, char**)
  {
      data info_1(10, true , 1);
      data info_2(20, true, 1);
      data info_3(10, false, 4);
  
      std::vector&lt;data&gt; data_vector;
  
      data_vector.push_back(info_1);
      data_vector.push_back(info_2);
  
      std::replace(data_vector.begin(), data_vector.end(), data_vector ,info_3);
  
      std::cout &lt;&lt; "vector size: " &lt;&lt; data_vector.size() &lt;&lt; "\n";
      for (int i = 0; i &lt; data_vector.size(); i++)
      {
          std::cout &lt;&lt; "group number: " &lt;&lt; data_vector[i].group &lt;&lt; std::boolalpha &lt;&lt; " condition: " &lt;&lt; data_vector[i].condition &lt;&lt; "\n";
      }
      system("pause");
      return 0;
  }
  </code></pre>