How to take an rvalue reference parameter and pass it on elsewhere?
<p>I am a reasonably competent C++ user (not a complete noob). I have a class that acts as a resource handle.  It makes sense for the class to have a move constructor and for the copy construtor to be deleted:</p>

<pre><code>struct Foo {

  Foo (int i) : // For sake of example.
    x(i)
  {}

  Foo (Foo &amp;&amp; f) :
    x(f.x)
  {
    f.x = 0; // 0 is special and means "moved from".
  }

  Foo (const Foo &amp; f) = delete;

private:
  int x;
};
</code></pre>

<p>I've been doing this in a cargo-cult fashion for ages now and it works fine.  Now I'm trying to step up a gear with my C++11 usage.</p>

<p>I have another class that keeps a <code>vector</code> of <code>Foo</code>:</p>

<pre><code>struct Bar { // (Constructor added below)
  std::vector&lt;Foo&gt; foos;
};
</code></pre>

<p>I'd like to write a constructor for <code>Bar</code> where the caller passes in a <code>vector&lt;Foo&gt;</code>.  I'd like the <em>entire vector</em> that the caller provides to be moved into <code>Bar.foos</code>.  I want to make that explicit to the caller by making the constructor parameter a <code>vector&lt;Foo&gt;&amp;&amp;</code> rather than a plain <code>vector&lt;Foo&gt;&amp;</code>.  That way, the caller must <code>std::move</code> the vector in to the constructor.</p>

<pre><code>int main (int argc, char ** argv)
{     
    Foo f1 (1);
    Foo f2 (2);
    std::vector&lt;Foo&gt; v;
    v.push_back (std::move(f1));
    v.push_back (std::move(f2));

    Bar b (std::move(v)); // I want the user to HAVE TO std::move v.
    return 0;
}
</code></pre>

<p>I naively tried writing <code>Bar</code> constructor like this:</p>

<pre><code>struct Bar {

  Bar (vector&lt;Foo&gt; &amp;&amp; vf) :
    foos (vf) // pass the rvalue reference into foos' constructor, right?
  {}

  std::vector&lt;Foo&gt; foos;
};
</code></pre>

<p>My computer has g++ 4.9.2 and clang++ 3.5.0 and they both give me a small explosion of errors.  They're both trying to construct <code>Bar.foos</code> using the vector <em>copy constructor</em>, which then fails because I've deleted the copy constructor of <code>Foo</code>.</p>

<p>How can I give 'vf', the rvalue reference of <code>vector&lt;Foo&gt;</code> straight to the constructor of 'foos'?</p>