title: Splitting deques inside vector
body: <p>I'm trying to deal with a very strange problem. I don't have much experience with STL containers so their mechanics are a big mystery for me. Ok, back to main topic. I need to create a vector of deques and then split every existing deque inside this vector in half. Each half will create seperate deque from now on.
  I'm expecting something like this:</p>
  
  <blockquote>
    <p>vector{ deque{1,2,3,4,5} } -----> vector { deque{1,2,3}, deque{4,5} }</p>
  </blockquote>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;deque&gt;
  #include &lt;vector&gt;
  
  int main() {
  
      std::vector&lt; std::deque&lt;int&gt; &gt; vector_of_deques;
      vector_of_deques.push_back( std::deque&lt;int&gt;{1, 2, 3, 4, 5} );
  
      std::deque&lt;int&gt; deque = *(vector_of_deques.begin());
      int split_position;
  
      if (deque.size() % 2 == 0)
          split_position = deque.size() / 2;
      else 
          split_position = int(deque.size() / 2) + 1;
  
      vector_of_deques.emplace_back( deque.begin() + split_position, deque.end() );
      deque.erase( deque.begin() + split_position, deque.end() );
  
      for (auto i: vector_of_deques) {
          for (auto j: i)
              std::cout &lt;&lt; j &lt;&lt; ", ";
  
          std::cout &lt;&lt; std::endl;
      }
  
      return 0;
  }
  </code></pre>
  
  <p>Output: </p>
  
  <blockquote>
    <p>1, 2, 3, 4, 5,</p>
    
    <p>4, 5,</p>
  </blockquote>
  
  <p>Expected:</p>
  
  <blockquote>
    <p>1, 2, 3,</p>
    
    <p>4, 5,</p>
  </blockquote>
  
  <p>I have not a single idea what's going on. Can someone explain me why my way of thinking about those containers is wrong? It would be a great help for me.</p>