title: Why is std::pair faster than std::tuple
body: <p>Here is the code for testing.</p>
  
  <p>Tuple test:</p>
  
  <pre><code>using namespace std;
  
  int main(){
  
      vector&lt;tuple&lt;int,int&gt;&gt; v;
  
  
      for (int var = 0; var &lt; 100000000; ++var) {
          v.push_back(make_tuple(var, var));
      }
  }
  </code></pre>
  
  <p>Pair test:</p>
  
  <pre><code>#include &lt;vector&gt;
  
  using namespace std;
  
  int main(){
  
      vector&lt;pair&lt;int,int&gt;&gt; v;
  
  
      for (int var = 0; var &lt; 100000000; ++var) {
          v.push_back(make_pair(var, var));
      }
  }
  </code></pre>
  
  <p>I did the time measurement via Linux time command.
  The results are:</p>
  
  <pre><code>|       |   -O0   |    -O2   |
  |:------|:-------:|:--------:|
  | Pair  |   8.9 s |  1.60 s  |
  | Tuple |  19.8 s |  1.96 s  |
  </code></pre>
  
  <p>I am wondering, why is such a big difference between those two data structures in O0, as they should be very similar. There is just a small difference in 02.</p>
  
  <p>Why is the difference in O0 so big, and why is there any difference at all?</p>
  
  <p>EDIT:</p>
  
  <p>The code with v.resize()</p>
  
  <p>Pair:</p>
  
  <pre><code>#include &lt;vector&gt;
  
  using namespace std;
  
  int main(){
  
      vector&lt;pair&lt;int,int&gt;&gt; v;
  
      v.resize(100000000);
  
      for (int var = 0; var &lt; 100000000; ++var) {
          v[var] = make_pair(var, var);
      }
  }
  </code></pre>
  
  <p>Tuple:</p>
  
  <pre><code>#include&lt;tuple&gt;
  #include&lt;vector&gt;
  
  using namespace std;
  
  int main(){
  
      vector&lt;tuple&lt;int,int&gt;&gt; v;
  
      v.resize(100000000);
  
      for (int var = 0; var &lt; 100000000; ++var) {
          v[var] = make_tuple(var, var);
      }
  }
  </code></pre>
  
  <p>Results:</p>
  
  <pre><code>|       |   -O0   |    -O2   |
  |:------|:-------:|:--------:|
  | Pair  |  5.01 s |  0.77 s  |
  | Tuple |  10.6 s |  0.87 s  |
  </code></pre>
  
  <p>EDIT:</p>
  
  <p>My system</p>
  
  <pre><code>g++ (GCC) 4.8.3 20140911 (Red Hat 4.8.3-7)
  GLIBCXX_3.4.19
  </code></pre>