title: How to split a vector into n "almost equal" parts
body: <p>I have a problem that I would like to merge a large number of images using ImageMagick's convert.exe, but under Windows I have a 8192 byte long command line limit. </p>
  
  <p>My solution to this is to split the task into smaller sub-task, run them, and do a final task which combines them together. </p>
  
  <p>My idea is to write a function, which takes a vector of images and an integer, and splits the vector into n sub-vector all having "almost equal" parts.</p>
  
  <p>So for example if I would like to split 11 into 3 groups it would be 4-4-3.</p>
  
  <p>Can you tell me how can I do it in C++? I mean, to write a function </p>
  
  <pre><code>split_vec( const vector&lt;image&gt; &amp;images, int split )
  </code></pre>
  
  <p>which does the splitting?</p>
  
  <p>Also, can you tell me what is the most efficient way to do <strong>if I don't need to create new vectors, just iterate through the sub-parts</strong>? Like the <code>std::substr</code> function with <code>std::string</code>?</p>
  
  <p><em>Note: I already use Boost in the project, so if there is some nice tool in Boost for this then it's perfect for me.</em></p>