title: I want to bind a a non-const lvalue reference to type T to a temporary of type T
body: <p>Is there a trick/cast letting me do that?</p>
  <pre><code>#include &lt;vector&gt;
  
  std::vector&lt;int&gt; getBar(){
    std::vector&lt;int&gt; bar (5,200);   // five ints with a value of 200    
    return bar;
  }
  
  int main ()
  {
    std::vector&lt;int&gt; foo (3,100);   // three ints with a value of 100
  
    foo.swap(getBar());
  
    return 0;
  }
  </code></pre>
  <p>In this specific case</p>
  <pre><code>foo = getBar(); 
  </code></pre>
  <p>is a good answer. I wonder if there is a way to accomplish that task for  functions other than <code>swap</code> taking a non const reference.</p>