title: C++ set allowing duplicates?
body: <p>I am attempting to solve the interview problem from leet code to remove duplicates from a vector of ints.</p>
  <p>Below is my my code for the answer:</p>
  <pre><code>#include &lt;vector&gt;
  #include &lt;set&gt;
  using namespace std;
  
  class Solution {
  public:
      int removeDuplicates(vector&lt;int&gt;&amp; nums) {
          vector&lt;int&gt;::iterator itr;
          set&lt;int&gt; temp;
  
          for (itr = nums.begin(); itr != nums.end(); itr++) {
              if (temp.insert(*itr).second == false) {
                  nums.erase(itr);
              }
          }
          return nums.size();
      }
  };
  </code></pre>
  <p>I've added includes for completion.</p>
  <p>The problem I've run into is if I have an input vector as so [0,0,1,1,2,2,3,3,4,4,5,5] my function will only erase the duplicates that are not 1 or 2.</p>
  <p>Thus my answer will be [0,1,1,2,2,3,4,5].  My understanding is that set will not allow duplicate values but I don't understand why 1 and 2 is still duplicated.</p>