title: What is the correct return in a function that modifies a potential r-value reference?
body: <p>Conceptually and practice, what is the correct way to return the modified value of a function that <em>potentially</em> takes a r-value reference.</p>
  
  <pre><code>template&lt;class Vector&gt;
  ??? add_element(Vector&amp;&amp; v){
      v.emplace_back(1.);
      return ???(v);
  }
  </code></pre>
  
  <p>Intuition tells me this, (because I don't loose information of the original type)</p>
  
  <pre><code>template&lt;class Vector&gt;
  Vector&amp;&amp; add_element(Vector&amp;&amp; v){
      v.emplace_back(1.);
      return std::forward&lt;Vector&gt;(v);
  }
  </code></pre>
  
  <p>but among other possibilities is</p>
  
  <pre><code>template&lt;class Vector&gt;
  Vector&amp; add_element(Vector&amp;&amp; v){
      v.emplace_back(1.);
      return v;
  }
  </code></pre>
  
  <p>or even these ones, (based on this <a href="https://pizer.wordpress.com/2009/04/13/c0x-do-people-understand-rvalue-references/" rel="nofollow noreferrer">https://pizer.wordpress.com/2009/04/13/c0x-do-people-understand-rvalue-references/</a> )</p>
  
  <pre><code>template&lt;class Vector&gt;
  Vector // or typename std::decay&lt;Vector&gt;::type 
  add_element(Vector&amp;&amp; v){
      v.emplace_back(1.);
      return v; // or std::forward&lt;Vector&gt;(v); 
  }
  </code></pre>
  
  <p><strong>What is the most generic way of returning the modified passed argument?</strong></p>