title: Should a constructor for a class that contains a move-only type receive the move-only type by reference or by rvalue reference?
body: <p>I recently started learning about move semantics, and I have been thinking about the following problem for a few days:</p>
  
  <p>Let's say we have a non-copyable class like the following:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>class Texture
  {
  public:
  
     Texture(unsigned int texID);
     ~Texture();
  
     Texture(const Texture&amp;) = delete;
     Texture&amp; operator=(const Texture&amp;) = delete;
  
     Texture(Texture&amp;&amp; rhs);
     Texture&amp; operator=(Texture&amp;&amp; rhs);
  
     // ...
  
  private:
  
     unsigned int mTexID;
  };
  </code></pre>
  
  <p>For those wondering, it is common to have such wrapper classes when working with OpenGL. The ID is used to access data that is stored in the GPU, and it is used to tell the GPU to destroy said data, which is done in the destructor of this wrapper class. That is why it is a non-copyable class.</p>
  
  <p>Now let's say we have another non-copyable class like the following:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>class Mesh
  {
  public:
  
     // Notice how the constructor receives the vector of Texture objects (a move-only type) by reference
     Mesh(const std::vector&lt;unsigned int&gt;&amp; indices, std::vector&lt;Texture&gt;&amp; textures)
        : mIndices(indices)
        , mTextures(std::move(textures))
     {
        // ...
     }
     ~Mesh();
  
     Mesh(const Mesh&amp;) = delete;
     Mesh&amp; operator=(const Mesh&amp;) = delete;
  
     Mesh(Mesh&amp;&amp; rhs);
     Mesh&amp; operator=(Mesh&amp;&amp; rhs);
  
     // ...
  
  private:
  
     std::vector&lt;unsigned int&gt; mIndices;
     std::vector&lt;Texture&gt;      mTextures;
  };
  </code></pre>
  
  <p>With the constructor the way it is right now, a client could create a <code>Mesh</code> by doing the following:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>std::vector&lt;unsigned int&gt; indices;
  std::vector&lt;Texture&gt; textures;
  
  // ...
  
  Mesh mesh(indices, textures); // Client is unaware that the textures vector has been moved from
  </code></pre>
  
  <p>My question is whether it would be better if the constructor of the <code>Mesh</code> class was declared like this:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>// Notice how the constructor receives the vector of Texture objects (a move-only type) by rvalue reference
  Mesh::Mesh(const std::vector&lt;unsigned int&gt;&amp; indices, std::vector&lt;Texture&gt;&amp;&amp; textures)
     : mIndices(indices)
     , mTextures(std::move(textures))
  {
     // ...
  }
  </code></pre>
  
  <p>With this new constructor, the client would be forced to do the following when creating a <code>Mesh</code> object:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>std::vector&lt;unsigned int&gt; indices;
  std::vector&lt;Texture&gt; textures;
  
  // ...
  
  Mesh mesh(indices, std::move(textures)); // Client is fully aware that the textures vector has been moved from
  </code></pre>
  
  <p>It is certainly more typing, but now the user is fully aware that the textures vector has been moved from, and I don't see any performance implications.</p>
  
  <p>So I guess my question is: are there are guidelines on what's the best way to receive move-only types that will be moved from? Receiving by reference to const clearly indicates that the type will not be moved from, so how does one do the opposite? How does one tell the client that the type will be moved from?</p>