title: How to erase vector element by pointer?
body: <p>I have this:</p>
  
  <pre><code>vector&lt;Object*&gt; myVec;
  </code></pre>
  
  <p>and adding my objects to it like this:</p>
  
  <pre><code>Object *obj1 = new Object;
  myVec.push_back(obj1);
  </code></pre>
  
  <p>Let's assume that I have 100 objects in this way and pointers going as *obj1, *obj2 ... *obj100.<br>
  And now I want to remove let's say, obj37, from the vector. I wish I could do that just like pushing it:</p>
  
  <pre><code>myVec.remove_back(obj37);
  </code></pre>
  
  <p>It would be awesome if there was a function like "remove_back" but there is not I think.
  I hope you got the point and please help me about that.</p>
  
  <p>By the way, just look at this <a href="https://stackoverflow.com/questions/3385229/c-erase-vector-element-by-value-rather-than-by-position">question</a>, in accepted answer, there is remove algorithm works by value:</p>
  
  <pre><code>vec.erase(std::remove(vec.begin(), vec.end(), 8), vec.end());
  </code></pre>
  
  <p>I gave it a shot that with pointer even I didn't believe that would work and surprise; it didn't:</p>
  
  <pre><code>myVec.erase(std::remove(myVec.begin(), myVec.end(), *obj37), vec.end());
  </code></pre>
  
  <p>Yeah, I know that I've just bullshit but that's for you got the point. Somewhere there should be a simple solution like this and I just want that.</p>