title: c++11 rvalue references in `std::make_pair`
body: <p>For C++98</p>
  
  <pre><code>template &lt;class T1, class T2&gt;
    pair&lt;T1,T2&gt; make_pair (T1 x, T2 y);
  </code></pre>
  
  <p>For C++11</p>
  
  <pre><code>template &lt;class T1, class T2&gt;
    pair&lt;V1,V2&gt; make_pair (T1&amp;&amp; x, T2&amp;&amp; y);  // see below for definition of V1 and V2
  </code></pre>
  
  <blockquote>
    <p>If T1 and/or T2 are rvalue references, the objects are moved and x
    and/or y are left in an undefined but valid state.</p>
  </blockquote>
  
  <pre><code>// make_pair example
  #include &lt;utility&gt;      // std::pair
  #include &lt;iostream&gt;     // std::cout
  #include &lt;functional&gt;
  #include &lt;unordered_set&gt;
  using namespace std;
  
  int main () {
    int i = 2;
    int j = 3;
  
    pair&lt;int, int&gt; p0 = make_pair&lt;int, int&gt;(2, 3); // fine
    pair&lt;int, int&gt; p1 = make_pair&lt;int, int&gt;(move(i), move(j)); // fine
    pair&lt;int, int&gt; p2 = make_pair&lt;int, int&gt;(i+0, j+0); // fine
    pair&lt;int, int&gt; p3 = pair&lt;int, int&gt;(i, j); // fine
  
    const int i2 = 2;
    const int j2 = 3;
    // error: no matching function for call to ‘make_pair(const int&amp;, const int&amp;)’
    pair&lt;int, int&gt; p4 = make_pair&lt;int, int&gt;(i2, j2); // wrong
  
    // error: no matching function for call to ‘make_pair(int&amp;, int&amp;)’
    pair&lt;int, int&gt; p5 = make_pair&lt;int, int&gt;(i, j); // wrong
  
    return 0;
  }
  </code></pre>
  
  <p>Question> I found that it is inconvenient to create a <code>pair</code> with non-rvalue reference variables by <code>make_pair</code>.
  As you can see above code, the following line doesn't compile.</p>
  
  <pre><code>  // error: no matching function for call to ‘make_pair(int&amp;, int&amp;)’
    pair&lt;int, int&gt; p4 = make_pair&lt;int, int&gt;(i, j); // wrong
  </code></pre>
  
  <p>In practice, how do you make use of <code>make_pair</code> with non-rvalue reference variables?</p>
  
  <p>Thank you</p>