title: c++ How to copy vector of struct into another vector of struct with kind of duplication
body: <p>How to copy vector of struct into another vector of struct such as:</p>
  
  <p>Let the first, and second vectors as:</p>
  
  <pre><code>std::vector &lt;myStruct&gt; OriginalVector 
  std::vector &lt;myStruct&gt; NewVector  
  </code></pre>
  
  <p>where:</p>
  
  <pre><code>struct Linkedvalues{
      int indx;
      double Val;
  };
  
  struct myStruct{
      std::vector&lt;int&gt; Id;
      double avg;
      std::vector&lt;Linkedvalues&gt; lValues;
      double sum= 0.0;
  };
  </code></pre>
  
  <p>in my program, I filled <code>OriginalVector</code> and i need to copy its values in <code>NewVector</code> with this duplication: </p>
  
  <p>let <code>OriginalVector</code> has the following values:</p>
  
  <pre><code>{ (1, 2), 0.6, {(1, 0.5), (3,0.1), (5,0.7)}, 1.5 } 
  { (1, 3), 0.5, {(1, 0.2), (4,0.9), (5,0.7)}, 3.1 } 
  { (2, 3), 0.1, {(3, 0.4), (2,0.2), (5,0.7)}, 4.2 } 
  { (3, 5), 0.3, {(2, 0.1), (3,0.6), (5,0.7)}, 7.5 } 
  </code></pre>
  
  <p>I want to create <code>NewVector</code> as:</p>
  
  <pre><code>{ (1, 2), 0.6, {(1, 0.5), (3,0.1), (5,0.7)}, 1.5 } 
  { (2, 1), 0.6, {(1, 0.5), (3,0.1), (5,0.7)}, 1.5 } // also add the same previous 
                                                     //vector but swap (1,2) to (2,1)  
  
  { (1, 3), 0.5, {(1, 0.2), (4,0.9), (5,0.7)}, 3.1 } 
  { (3, 1), 0.5, {(1, 0.2), (4,0.9), (5,0.7)}, 3.1 }  // also add the same previous 
                                                     //vector but swap (1,3) to (3,1)
  
  { (2, 3), 0.1, {(3, 0.4), (2,0.2), (5,0.7)}, 4.2 } 
  { (3, 2), 0.1, {(3, 0.4), (2,0.2), (5,0.7)}, 4.2 } //also add the same previous 
                                                     //vector but swap (2,3) to (3,2)
  
  { (3, 5), 0.3, {(2, 0.1), (3,0.6), (5,0.7)}, 7.5 } 
  { (5, 3), 0.3, {(2, 0.1), (3,0.6), (5,0.7)}, 7.5 }  //also add the same previous 
                                                     //vector but swap (3,5) to (5,3)
  </code></pre>
  
  <p>In order to do that, I did the following:</p>
  
  <pre><code>int i=0;
  while (i &lt; OriginalVector.size())
  {
   auto it = (std::make_pair(OriginalVector[i].id.front(), OriginalVector[i].id.back()));
   auto itt = (std::make_pair(OriginalVector[i].id.back(), OriginalVector[i].id.front()));
  
  // Here I fail to insert it and itt with the rest of OriginalVector[i] members into NewVector 
  ++i;
  }
  </code></pre>