title: Can a lvalue-ref-qualified function be used directly in a rvalue-ref-qualified function?
body: <p>I have been writing the following code to support function calls on rvalues without having to <code>std::move</code> explicitly on the return value.</p>
  
  <pre><code>struct X {
      X&amp; do_something() &amp; {
          // some code
  
          return *this;
      }
  
      X&amp;&amp; do_something() &amp;&amp; {
          // some code
  
          return std::move(*this);
      }};
  </code></pre>
  
  <p>But this results in having to repeat the code inside the function. Preferably, I would do something like</p>
  
  <pre><code>struct X {
      X&amp; do_something() &amp; {
          // some code
  
          return *this;
      }
  
      X&amp;&amp; do_something() &amp;&amp; {
          return std::move(do_something());
      }};
  </code></pre>
  
  <p>Is this a valid transformation? Why or why not?</p>
  
  <p>Also, I can't help but feel that there's some knowledge gap w.r.t ref-qualifiers. Is there a general way (or a set of rules) of figuring out if code like this is valid or not?</p>