title: c++ concatenate many std::vectors and remove duplicates
body: <p>I am receiving some integers from an external API (std::vector). </p>
  
  <p>The API usually needs to be called multiple times, so I need to accumulate all the integers from the consecutive API calls to a local vector. At the end every element of the array must be unique (does not need to be sorted).</p>
  
  <p>My code is below (uses the getNextVector to "mock" data and simulate the API call). </p>
  
  <p>The code works, however I want maximum performance for this operation. Is my approach the right one? </p>
  
  <pre><code>#include &lt;vector&gt;
  #include &lt;iostream&gt;
  #include &lt;iterator&gt;
  #include &lt;algorithm&gt;
  
  std::vector&lt;int&gt; getNextVector(int i) {
      if ( i == 0 ) {
          std::vector&lt;int&gt; v = { 1,2,3 };
          return v; 
      } else if ( i == 1 ) {
          std::vector&lt;int&gt; v = { 3,4,5 };
          return v; 
      } else if ( i == 2 ) {
          std::vector&lt;int&gt; v = { 5,6,7 };
          return v; 
      } else if ( i == 3 ) {
          std::vector&lt;int&gt; v = { 7,8,9 };
          return v; 
      }
  }
  
  int count() { return 4; } //we have four vectors
  
  int main(int argc, char** argv) {
  
      std::vector&lt;int&gt; dest;
      dest.reserve(20); // we can find this, for simplicity hardcode...
  
      for( int i = 0; i &lt; count(); i++ ) {
          std::vector&lt;int&gt; src = getNextVector(i);
          dest.insert(
              dest.end(),
              std::make_move_iterator(src.begin()),
              std::make_move_iterator(src.end())
          );
      }
  
      std::sort(dest.begin(), dest.end());
      dest.erase(unique(dest.begin(), dest.end()), dest.end());
  /*
      std::copy(
        dest.begin(),
        dest.end(),
        std::ostream_iterator&lt;int&gt;(std::cout, "\n")
      );
  */
      return 0;
  }
  </code></pre>