title: Most efficient way to split a vector into several
body: <p>I have the following code which break up vectorOfInterest into smaller blocks to send out.
  this code is working.</p>
  
  <p>However, I do a copy when I split the vectorOfInterest into smaller chunks (in the constructor of subList and remainder).
  is there a better to use move instead of duplicating the data again for better performance?</p>
  
  <p>note that i cannot change the argument of OTHERCLASS::doSend()</p>
  
  <p>Edit: i am using C++98</p>
  
  <pre><code>int blockSize = 50;
  vector &lt;CLASS_T&gt; vectorOfInterest; 
  
  // ...&lt;populates vectorOfInterest&gt;
  do {
      if(vectorOfInterest.size()&gt; blockSize)
          vector&lt;CLASS_T&gt;iterator from = vectorOfInterest.begin();
          vector&lt;CLASS_T&gt;iterator to = from + blockSize;
  
          //elements are copied again in subList and remainder
          //I like to move the elements from vectorOfInterest instead.
          vector&lt;CLASS_T&gt; subList (from, to);  
          vector&lt;CLASS_T&gt; remainder (to, vectorOfInterest.end());
          vectorOfInterest.swap(remainder);
  
          OTHERCLASS::doSend (subList); // method which sends sublists in blocks of exactly 50 to external library
      }else {
          //pad to exactly size 50 
          vectorOfInterest.resize(blockSize);
  
           OTHERCLASS::dosend (vectorOfInterest); // method which sends sublists in blocks of exactly 50 to external library
  
          vectorOfInterest.clear();
      }
  
  while ( !vectorOfInterest.empty());
  </code></pre>