title: Can't remove element by ID from vector of non primitive datatypes
body: <p>I have a vector of my user-defined data type <code>city</code>. I'm trying to remove an element from this vector by its ID; eventually all cities will be removed from this list in a <code>while(!cityList.empty())</code> loop. I plan to use the erase-remove idiom to accomplish this. </p>
  
  <p>However, I'm getting a very gnarly error message when I <em>make</em> my code after calling <code>remove()</code>. Passing in the <code>city</code> object as the third parameter to <code>remove()</code> results in this error, as does passing in the (int) ID of the <code>city</code>. This error doesn't occur with <code>erase()</code>, but does with <code>remove()</code>, and also <code>find()</code> if I try to use that. Here is the code in question:</p>
  
  <pre><code>vector&lt;city&gt; cityList;
  cityList.push_back(city(1));
  cityList.push_back(city(2));
  cityList.push_back(city(3));
  
  city cityToRemove = cityList[0];
  int idOfCityToRemove = cityList[0].getID();
  
  remove(cityList.begin(), cityList.end(), cityToRemove);
  //remove(cityList.begin(), cityList.end(), idOfCityToRemove);
  </code></pre>
  
  <p><a href="http://www.tutorialspoint.com/compile_cpp_online.php?PID=0Bw_CjBb95KQMSG5OMVlJQ3NhMEE" rel="nofollow">Here is an updated simple, minimal demo of my problem</a>.</p>
  
  <p>The error message includes <em>"template argument deduction/substitution failed"</em> and <em>"‘city’ is not derived from ‘const _gnu_cxx::__normal_iterator&lt;_IteratorL, _Container>’ "</em> messages, and I haven't been able to find anything online relating to my problem with the above errors.</p>
  
  <p>Edit: I've modified my code such that I now have:</p>
  
  <pre><code>int main(int argc, char** argv) {
  
  vector&lt;city&gt; cityList;
  cityList.push_back(city(1));
  cityList.push_back(city(2));
  cityList.push_back(city(3));
  
  city cityToRemove = cityList[0];
  int idOfCityToRemove = cityList[0].getID();
  int i;
  
  for (i = 0; i &lt; cityList.size(); i++) {
      cityList.erase(remove_if(cityList.begin(), cityList.end(),  cityList[i] == cityToRemove), cityList.end());
  }
  //remove(cityList.begin(), cityList.end(), cityToRemove);
  //remove(cityList.begin(), cityList.end(), idOfCityToRemove);
  
  return 0;
  }
  
  bool operator ==(const city &amp;a, const city &amp;b)
  {
      return (a.id == b.id);
  }
  </code></pre>
  
  <p>and the error I receive when attempting to compile is:</p>
  
  <pre><code>In file included from /usr/include/c++/5/bits/stl_algobase.h:71:0,
               from /usr/include/c++/5/bits/char_traits.h:39,
               from /usr/include/c++/5/ios:40,
               from /usr/include/c++/5/ostream:38,
               from /usr/include/c++/5/iostream:39,
               from main.cpp:2:
  /usr/include/c++/5/bits/predefined_ops.h: In instantiation of ‘bool __gnu_cxx::__ops::_Iter_pred&lt;_Predicate&gt;::operator()(_Iterator) [with _Iterator = __gnu_cxx::__normal_iterator&lt;city*, std::vector&lt;city&gt; &gt;; _Predicate = bool]’:
  /usr/include/c++/5/bits/stl_algo.h:866:20:   required from _ForwardIterator std::__remove_if(_ForwardIterator, _ForwardIterator, _Predicate) [with _ForwardIterator = __gnu_cxx::__normal_iterator&lt;city*, std::vector&lt;city&gt; &gt;; _Predicate = __gnu_cxx::__ops::_Iter_pred&lt;bool&gt;]’
  /usr/include/c++/5/bits/stl_algo.h:936:30:   required from ‘_FIter std::remove_if(_FIter, _FIter, _Predicate) [with _FIter = __gnu_cxx::__normal_iterator&lt;city*, std::vector&lt;city&gt; &gt;; _Predicate = bool]’
  main.cpp:30:90:   required from here
  /usr/include/c++/5/bits/predefined_ops.h:234:30: error: expression cannot be used as a function
  { return bool(_M_pred(*__it)); }
                            ^
  </code></pre>
  
  <p>This is closer, but I'm not sure what is required. The line <code>main.cpp:30:90</code> points to the <code>cityList[i] == cityToRemove</code> part of my <code>cityList.erase()</code> function, however, so I know that the issue is within my comparison expression.</p>
  
  <p>My demo is also updated.</p>