Why copy constructor is called in std::vector's initializer list?
<p>I have the following very simple class:</p>

<pre><code>class Foo 
{
public:
  Foo() {}
  Foo(const Foo&amp;) = delete;
  Foo(Foo&amp;&amp;) {}

  void operator=(const Foo&amp;) = delete;
  void operator=(Foo&amp;&amp;) {}

  void dump() const {}
};
</code></pre>

<p>The class is move constructible and assignable but isn't copy constructible and assignable.</p>

<p>I'd like to initialize a vector of Foo elements using vector's initializer list.</p>

<pre><code>std::vector&lt;Foo&gt; vf = { Foo() };
</code></pre>

<p>The compiler complains because code has to use the deleted copy constructor. Could anybody explain, why the move construct is not used in this case, and why copy of the object is needed?</p>

<p>The following also requires the copy constructor and does not work either:</p>

<pre><code>std::vector&lt;Foo&gt; vf = { std::move(Foo()) };
</code></pre>

<p>On the other hand, this works fine (the move constructor is called):</p>

<pre><code>std::vector&lt;Foo&gt; vf;
vf.push_back(Foo());
</code></pre>

<p>Thanks for the explanation... :)</p>

<p><strong>Update:</strong></p>

<p>A suggested <a href="https://stackoverflow.com/questions/8193102/initializer-list-and-move-semantics">this</a> post explains my question.</p>

<p>Furthermore let's consider the following code (together with <code>class Foo</code> above):</p>

<pre><code>class Bar {
public:
    Bar(std::initializer_list&lt;Foo&gt; _l) {
        std::cout &lt;&lt; "Bar::Bar()" &lt;&lt; std::endl;
        for (auto&amp; e : _l)
            e.dump();
    }
};

int main() {
    Bar b { Foo() };
    return 0;
}
</code></pre>

<p>This produces the following output (compiled with C++11):</p>

<pre><code>Foo::Foo()
Bar::Bar()
Foo::dump()
Foo::~Foo()
</code></pre>

<p>It can be seen, that the initializer list is not actually filled with the 'copy of the objects' stated between the braces. This might be not true from C++14.</p>