title: Is std::move(*this) a good pattern?
body: <p>In order to make this code with C++11 reference qualifiers work as expected I have to introduce a <code>std::move(*this)</code> that doesn't sound right.</p>
  <pre><code>#include&lt;iostream&gt;
  struct A{
      void gun() const&amp;{std::cout &lt;&lt; &quot;gun const&amp;&quot; &lt;&lt; std::endl;}
      void gun() &amp;&amp;{std::cout &lt;&lt; &quot;gun&amp;&amp;&quot; &lt;&lt; std::endl;}
      void fun() const&amp;{gun();}
      void fun() &amp;&amp;{std::move(*this).gun();} // &lt;-- is this correct? or is there a better option
  };
  
  int main(){
      A a; a.fun(); // prints gun const&amp;
      A().fun(); // prints gun&amp;&amp;
  }
  </code></pre>
  <p>Something doesn't sound right about it. <strong>Is the <code>std::move</code> necessary? Is this a recommended use for it?</strong> For the moment if I don't use it I get <code>gun const&amp;</code> in both cases which is not the expected result.</p>
  <p>(It seems that <code>*this</code> is implicit and lvalue reference always, which makes sense but then the only way to escape to use <code>move</code>)</p>
  <p>Tested with <code>clang 3.4</code> and <code>gcc 4.8.3</code>.</p>
  <hr />
  <p><strong>EDIT</strong>: This is what I understand from @hvd answer:</p>
  <ol>
  <li><p><code>std::move(*this)</code> is syntactically and conceptually correct</p>
  </li>
  <li><p>However, if <code>gun</code> is not part of the desired interface, there no reason to overload the lv-ref and rv-ref version of it. And two functions with different names can do the same job. After all the ref-qualifiers matters at the interface level, which is generally only the public part.</p>
  </li>
  </ol>
  <pre><code>struct A{
  private:
      void gun() const{std::cout &lt;&lt; &quot;gun const&amp;&quot; &lt;&lt; std::endl;}
      void gun_rv(){std::cout &lt;&lt; &quot;gun called from fun&amp;&amp;&quot; &lt;&lt; std::endl;}
  public:
      void fun() const&amp;{gun();}
      void fun() &amp;&amp;{gun_rv();} // no need for `std::move(*this)`.
  };
  </code></pre>
  <p>But again, if <code>gun</code> is part of the (generic) interface then <code>std::move(*this)</code> is necessary, but only then. And also, even if <code>gun</code> is not part of the interface there readability advantages in not splitting the function <code>gun</code> as two differently named function and the cost of this is, well..., <code>std::move(*this)</code>.</p>
  <p><strong>EDIT 2</strong>: In retrospect this is similar to the C++98 case of <code>const</code> and no-<code>const</code> overload of the same function. In <em>some cases</em> it makes sense to use <code>const_cast</code> (another form of cast) to not repeat code and have the two functions with the same name (<a href="https://stackoverflow.com/a/124209/225186">https://stackoverflow.com/a/124209/225186</a>).
  ... although in more complicated cases it makes sense to have auxiliary private  functions that delegate the correct behavior for the interface function.</p>