title: Splitting range into sub-ranges
body: <p>I have a container std::vector and I would like to efficiently split it into sub-ranges with x items in each. The original container is not needed so the items should be moved and not copied into the sub-ranges.</p>
  
  <p>I've managed to do the splitting using copying, however I'm unsure how to do it with move assignments?</p>
  
  <pre><code>    range.insert(range.end(), new_items.begin(), new_items.end());
      while(range.size() &gt;= x)
      {
          sub_ranges.push_back(std::vector&lt;int&gt;(range.begin(), range.begin() + x));
          range = std::vector&lt;int&gt;(range.begin() + x, range.end());
      }
  </code></pre>
  
  <p>EDIT:</p>
  
  <p>Some progress... still not quite there, and a bit ugly</p>
  
  <pre><code>    while(range.size() &gt;= x)
      {
          std::vector&lt;short&gt; sub_range(x); // Unnecessary allocation?
          std::move(range.begin(), range.begin() + x, sub_range.begin());
          sub_ranges_.push_back(std::move(sub_range));
  
          std::move(range.begin() + x, range.end(), range.begin());
          range.resize(range.size() - x);
      }
  </code></pre>