title: std::pair<U,V> alignment control
body: <p>I noticed one unpleasant thing that happens with std::pair when tried to save it into binary file: std::pair is aligned to a word. It might be useful in terms of processor efficiency, but requires more storage space, so I want to switch align mode to 1-byte for std::pair. My compiler is MS VC++ 2012.</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  int main( )
  {
      struct S_a { double a; size_t b; };
  
  #pragma pack(1)
      struct S_wa { double a; size_t b; };
  
      std::cout &lt;&lt; sizeof( size_t ) &lt;&lt; '\n';                          // 4
      std::cout &lt;&lt; sizeof( double ) &lt;&lt; '\n';                          // 8
      std::cout &lt;&lt; sizeof( std::pair&lt; size_t, size_t &gt; ) &lt;&lt; '\n';     // 8
      std::cout &lt;&lt; sizeof( std::pair&lt; double, size_t &gt; ) &lt;&lt; '\n';     // 16 - bad
      std::cout &lt;&lt; sizeof( S_wa ) &lt;&lt; '\n';                            // 12 - good
      std::cout &lt;&lt; sizeof( S_a ) &lt;&lt; '\n';                             // 16
      std::cout &lt;&lt; sizeof( std::pair&lt; double, double &gt; ) &lt;&lt; '\n';     // 16
  }
  </code></pre>
  
  <p>I tried this, but it doesn't work:</p>
  
  <pre><code>#pragma pack(1)
      typedef std::pair&lt; double, size_t &gt; Q;
  
      std::cout &lt;&lt; sizeof( Q ) &lt;&lt; '\n';                               // 16
  </code></pre>