title: implement method with ref qualifier
body: <p>I have trouble to implement following code</p>
  
  <pre><code>template &lt;class T&gt;
  struct Foo
  {
      std::vector&lt;T&gt; vec;
  
      std::vector&lt;T&gt; getVector() &amp;&amp; {
          // fill vector if empty
          // and some other work
          return std::move(vec);
      }
  
      std::vector&lt;T&gt; getVectorAndMore() &amp;&amp;
      {
          // do some more work
          //return getVector(); // not compile
          return std::move(*this).getVector(); // seems wrong to me
      }
  };
  
  int main()
  {
      Foo&lt;int&gt; foo;
  
      auto vec = std::move(foo).getVectorAndMore();
  }
  </code></pre>
  
  <p>The problem is that I can't call <code>getVector</code> inside <code>getVectorAndMore</code> because <code>this</code> is not rvalue. To make the code compile, I had to cast <code>this</code> to rvalue.</p>
  
  <p>Is any good way to implement such code? </p>
  
  <hr>
  
  <p>with <code>return getVector();</code></p>
  
  <p>error message is</p>
  
  <pre><code>main.cpp:17:16: error: cannot initialize object parameter of type 'Foo&lt;int&gt;' with an expression of type 'Foo&lt;int&gt;'
          return getVector(); // not compile
                 ^~~~~~~~~
  main.cpp:26:31: note: in instantiation of member function 'Foo&lt;int&gt;::getVectorAndMore' requested here
      auto vec = std::move(foo).getVectorAndMore();
                                ^
  1 error generated.
  </code></pre>
  
  <p><a href="http://coliru.stacked-crooked.com/a/23aa6a4a4e8d07c4">Coliru</a></p>