title: Object rvalue propagation for member function calls
body: <p>I have a struct <code>F</code> with a function <code>foo</code> that has different implementation whether <code>F</code> is a temporary or not</p>
  <pre><code>struct  F{
    void foo() &amp;  { std::cout &lt;&lt; &quot;F::foo() &amp;&quot; &lt;&lt; std::endl; }
    void foo() &amp;&amp; { std::cout &lt;&lt; &quot;F::foo() &amp;&amp;&quot; &lt;&lt; std::endl; }
  };
  </code></pre>
  <p>Another struct <code>A</code> has a copy of <code>F</code> and in its function <code>bar</code> calls <code>F::foo</code>. I want to use the correct version of <code>F::foo()</code>. Therefore the implementation is:</p>
  <pre><code>struct A{
  
    void bar() &amp; {
      f.foo();
    }
  
    void bar() &amp;&amp; {
      std::move(f).foo();
    }
  
    F f;
  };
  </code></pre>
  <p>I'm wondering if I really have to provide two implementations of <code>A::bar()</code>. Isn't there a smart way to use <code>std::forward</code> to automatically decide which <code>F::foo()</code> should be used?</p>
  <hr />
  <p>An attempt:</p>
  <pre><code>struct B{
  
    void bar() {
      std::forward&lt;F&gt;(f).foo();
    }
    
    F f;
  };
  </code></pre>
  <p>However, this does not work. It calls <code>F::foo() &amp;&amp;</code> every time.</p>
  <hr />
  <h2><a href="https://godbolt.org/z/q4Mfz3" rel="noreferrer">Complete example</a></h2>