title: Moving std::list<std::unique_ptr> into vector attempts to reference a deleted function
body: <p>Here is a complete program which reproduces my problem.</p>
  
  <pre><code>#include &lt;vector&gt;
  #include &lt;list&gt;
  #include &lt;memory&gt;
  #include &lt;utility&gt;
  
  int main()
  {
      std::vector&lt;std::list&lt;std::unique_ptr&lt;int&gt;&gt;&gt; v;
  
      std::list&lt;std::unique_ptr&lt;int&gt;&gt; l;
      l.push_back(std::make_unique&lt;int&gt;(0));
      l.push_back(std::make_unique&lt;int&gt;(1));
  
      v.push_back(std::move(l)); // error
  }
  </code></pre>
  
  <p>On the last line the compiler is complaining that the <code>delete</code>d copy constructor of <code>std::unique_ptr</code> is being referenced. </p>
  
  <p>Since I'm <em>moving</em> the list into the vector, I assume no copy constructors will be called on the elements of the list. </p>
  
  <p>Why is this happening? How would I go about fixing it?</p>
  
  <p>I'm using MSVC 2017. </p>
  
  <p><a href="https://godbolt.org/g/Ky2JyN" rel="noreferrer"><strong>live example on godbolt</strong></a></p>
  
  <p>Full text from the error:</p>
  
  <pre><code>example.cpp
  /opt/compiler-explorer/windows/19.10.25017/lib/native/include/xmemory0(840): error C2280: 'std::unique_ptr&lt;int,std::default_delete&lt;_Ty&gt;&gt;::unique_ptr(const std::unique_ptr&lt;_Ty,std::default_delete&lt;_Ty&gt;&gt; &amp;)': attempting to reference a deleted function
          with
          [
              _Ty=int
          ]
  /opt/compiler-explorer/windows/19.10.25017/lib/native/include/memory(1857): note: see declaration of 'std::unique_ptr&lt;int,std::default_delete&lt;_Ty&gt;&gt;::unique_ptr'
          with
          [
              _Ty=int
          ]
  /opt/compiler-explorer/windows/19.10.25017/lib/native/include/xmemory0(959): note: see reference to function template instantiation 'void std::allocator&lt;_Other&gt;::construct&lt;_Objty,const std::unique_ptr&lt;int,std::default_delete&lt;_Ty&gt;&gt;&amp;&gt;(_Objty *,const std::unique_ptr&lt;_Ty,std::default_delete&lt;_Ty&gt;&gt; &amp;)' being compiled
          with
          [
              _Other=std::_List_node&lt;std::unique_ptr&lt;int,std::default_delete&lt;int&gt;&gt;,void *&gt;,
              _Objty=std::unique_ptr&lt;int,std::default_delete&lt;int&gt;&gt;,
              _Ty=int
          ]
  /opt/compiler-explorer/windows/19.10.25017/lib/native/include/xmemory0(959): note: see reference to function template instantiation 'void std::allocator&lt;_Other&gt;::construct&lt;_Objty,const std::unique_ptr&lt;int,std::default_delete&lt;_Ty&gt;&gt;&amp;&gt;(_Objty *,const std::unique_ptr&lt;_Ty,std::default_delete&lt;_Ty&gt;&gt; &amp;)' being compiled
          with
          [
              _Other=std::_List_node&lt;std::unique_ptr&lt;int,std::default_delete&lt;int&gt;&gt;,void *&gt;,
              _Objty=std::unique_ptr&lt;int,std::default_delete&lt;int&gt;&gt;,
              _Ty=int
          ]
  /opt/compiler-explorer/windows/19.10.25017/lib/native/include/xmemory0(1097): note: see reference to function template instantiation 'void std::allocator_traits&lt;_Alloc&gt;::construct&lt;_Ty,const std::unique_ptr&lt;int,std::default_delete&lt;int&gt;&gt;&amp;&gt;(std::allocator&lt;_Other&gt; &amp;,_Objty *,const std::unique_ptr&lt;int,std::default_delete&lt;int&gt;&gt; &amp;)' being compiled
          with
          [
              _Alloc=std::allocator&lt;std::_List_node&lt;std::unique_ptr&lt;int,std::default_delete&lt;int&gt;&gt;,void *&gt;&gt;,
              _Ty=std::unique_ptr&lt;int,std::default_delete&lt;int&gt;&gt;,
              _Other=std::_List_node&lt;std::unique_ptr&lt;int,std::default_delete&lt;int&gt;&gt;,void *&gt;,
              _Objty=std::unique_ptr&lt;int,std::default_delete&lt;int&gt;&gt;
          ]
  /opt/compiler-explorer/windows/19.10.25017/lib/native/include/xmemory0(1096): note: see reference to function template instantiation 'void std::allocator_traits&lt;_Alloc&gt;::construct&lt;_Ty,const std::unique_ptr&lt;int,std::default_delete&lt;int&gt;&gt;&amp;&gt;(std::allocator&lt;_Other&gt; &amp;,_Objty *,const std::unique_ptr&lt;int,std::default_delete&lt;int&gt;&gt; &amp;)' being compiled
          with
          [
              _Alloc=std::allocator&lt;std::_List_node&lt;std::unique_ptr&lt;int,std::default_delete&lt;int&gt;&gt;,void *&gt;&gt;,
              _Ty=std::unique_ptr&lt;int,std::default_delete&lt;int&gt;&gt;,
              _Other=std::_List_node&lt;std::unique_ptr&lt;int,std::default_delete&lt;int&gt;&gt;,void *&gt;,
              _Objty=std::unique_ptr&lt;int,std::default_delete&lt;int&gt;&gt;
          ]
  /opt/compiler-explorer/windows/19.10.25017/lib/native/include/list(853): note: see reference to function template instantiation 'void std::_Wrap_alloc&lt;std::allocator&lt;_Other&gt;&gt;::construct&lt;_Ty,const std::unique_ptr&lt;int,std::default_delete&lt;int&gt;&gt;&amp;&gt;(_Ty *,const std::unique_ptr&lt;int,std::default_delete&lt;int&gt;&gt; &amp;)' being compiled
          with
          [
              _Other=std::_List_node&lt;std::unique_ptr&lt;int,std::default_delete&lt;int&gt;&gt;,void *&gt;,
              _Ty=std::unique_ptr&lt;int,std::default_delete&lt;int&gt;&gt;
          ]
  /opt/compiler-explorer/windows/19.10.25017/lib/native/include/list(851): note: see reference to function template instantiation 'void std::_Wrap_alloc&lt;std::allocator&lt;_Other&gt;&gt;::construct&lt;_Ty,const std::unique_ptr&lt;int,std::default_delete&lt;int&gt;&gt;&amp;&gt;(_Ty *,const std::unique_ptr&lt;int,std::default_delete&lt;int&gt;&gt; &amp;)' being compiled
          with
          [
              _Other=std::_List_node&lt;std::unique_ptr&lt;int,std::default_delete&lt;int&gt;&gt;,void *&gt;,
              _Ty=std::unique_ptr&lt;int,std::default_delete&lt;int&gt;&gt;
          ]
  /opt/compiler-explorer/windows/19.10.25017/lib/native/include/list(1086): note: see reference to function template instantiation 'std::_List_node&lt;std::unique_ptr&lt;int,std::default_delete&lt;_Ty&gt;&gt;,void *&gt; *std::_List_buy&lt;std::unique_ptr&lt;_Ty,std::default_delete&lt;_Ty&gt;&gt;,_Alloc&gt;::_Buynode&lt;const std::unique_ptr&lt;_Ty,std::default_delete&lt;_Ty&gt;&gt;&amp;&gt;(std::_List_node&lt;std::unique_ptr&lt;_Ty,std::default_delete&lt;_Ty&gt;&gt;,void *&gt; *,std::_List_node&lt;std::unique_ptr&lt;_Ty,std::default_delete&lt;_Ty&gt;&gt;,void *&gt; *,const std::unique_ptr&lt;_Ty,std::default_delete&lt;_Ty&gt;&gt; &amp;)' being compiled
          with
          [
              _Ty=int,
              _Alloc=std::allocator&lt;std::unique_ptr&lt;int,std::default_delete&lt;int&gt;&gt;&gt;
          ]
  /opt/compiler-explorer/windows/19.10.25017/lib/native/include/list(1085): note: see reference to function template instantiation 'std::_List_node&lt;std::unique_ptr&lt;int,std::default_delete&lt;_Ty&gt;&gt;,void *&gt; *std::_List_buy&lt;std::unique_ptr&lt;_Ty,std::default_delete&lt;_Ty&gt;&gt;,_Alloc&gt;::_Buynode&lt;const std::unique_ptr&lt;_Ty,std::default_delete&lt;_Ty&gt;&gt;&amp;&gt;(std::_List_node&lt;std::unique_ptr&lt;_Ty,std::default_delete&lt;_Ty&gt;&gt;,void *&gt; *,std::_List_node&lt;std::unique_ptr&lt;_Ty,std::default_delete&lt;_Ty&gt;&gt;,void *&gt; *,const std::unique_ptr&lt;_Ty,std::default_delete&lt;_Ty&gt;&gt; &amp;)' being compiled
          with
          [
              _Ty=int,
              _Alloc=std::allocator&lt;std::unique_ptr&lt;int,std::default_delete&lt;int&gt;&gt;&gt;
          ]
  /opt/compiler-explorer/windows/19.10.25017/lib/native/include/list(1463): note: see reference to function template instantiation 'void std::list&lt;std::unique_ptr&lt;int,std::default_delete&lt;_Ty&gt;&gt;,std::allocator&lt;std::unique_ptr&lt;_Ty,std::default_delete&lt;_Ty&gt;&gt;&gt;&gt;::_Insert&lt;const std::unique_ptr&lt;_Ty,std::default_delete&lt;_Ty&gt;&gt;&amp;&gt;(std::_List_unchecked_const_iterator&lt;std::_List_val&lt;std::_List_simple_types&lt;std::unique_ptr&lt;_Ty,std::default_delete&lt;_Ty&gt;&gt;&gt;&gt;,std::_Iterator_base0&gt;,const std::unique_ptr&lt;_Ty,std::default_delete&lt;_Ty&gt;&gt; &amp;)' being compiled
          with
          [
              _Ty=int
          ]
  /opt/compiler-explorer/windows/19.10.25017/lib/native/include/list(1463): note: see reference to function template instantiation 'void std::list&lt;std::unique_ptr&lt;int,std::default_delete&lt;_Ty&gt;&gt;,std::allocator&lt;std::unique_ptr&lt;_Ty,std::default_delete&lt;_Ty&gt;&gt;&gt;&gt;::_Insert&lt;const std::unique_ptr&lt;_Ty,std::default_delete&lt;_Ty&gt;&gt;&amp;&gt;(std::_List_unchecked_const_iterator&lt;std::_List_val&lt;std::_List_simple_types&lt;std::unique_ptr&lt;_Ty,std::default_delete&lt;_Ty&gt;&gt;&gt;&gt;,std::_Iterator_base0&gt;,const std::unique_ptr&lt;_Ty,std::default_delete&lt;_Ty&gt;&gt; &amp;)' being compiled
          with
          [
              _Ty=int
          ]
  /opt/compiler-explorer/windows/19.10.25017/lib/native/include/list(1423): note: see reference to function template instantiation 'void std::list&lt;std::unique_ptr&lt;int,std::default_delete&lt;_Ty&gt;&gt;,std::allocator&lt;std::unique_ptr&lt;_Ty,std::default_delete&lt;_Ty&gt;&gt;&gt;&gt;::_Insert_range&lt;_Iter&gt;(std::_List_unchecked_const_iterator&lt;std::_List_val&lt;std::_List_simple_types&lt;std::unique_ptr&lt;_Ty,std::default_delete&lt;_Ty&gt;&gt;&gt;&gt;,std::_Iterator_base0&gt;,_Iter,_Iter,std::forward_iterator_tag)' being compiled
          with
          [
              _Ty=int,
              _Iter=std::_List_const_iterator&lt;std::_List_val&lt;std::_List_simple_types&lt;std::unique_ptr&lt;int,std::default_delete&lt;int&gt;&gt;&gt;&gt;&gt;
          ]
  /opt/compiler-explorer/windows/19.10.25017/lib/native/include/list(1422): note: see reference to function template instantiation 'void std::list&lt;std::unique_ptr&lt;int,std::default_delete&lt;_Ty&gt;&gt;,std::allocator&lt;std::unique_ptr&lt;_Ty,std::default_delete&lt;_Ty&gt;&gt;&gt;&gt;::_Insert_range&lt;_Iter&gt;(std::_List_unchecked_const_iterator&lt;std::_List_val&lt;std::_List_simple_types&lt;std::unique_ptr&lt;_Ty,std::default_delete&lt;_Ty&gt;&gt;&gt;&gt;,std::_Iterator_base0&gt;,_Iter,_Iter,std::forward_iterator_tag)' being compiled
          with
          [
              _Ty=int,
              _Iter=std::_List_const_iterator&lt;std::_List_val&lt;std::_List_simple_types&lt;std::unique_ptr&lt;int,std::default_delete&lt;int&gt;&gt;&gt;&gt;&gt;
          ]
  /opt/compiler-explorer/windows/19.10.25017/lib/native/include/list(939): note: see reference to function template instantiation 'std::_List_iterator&lt;std::_List_val&lt;std::_List_simple_types&lt;std::unique_ptr&lt;int,std::default_delete&lt;_Ty&gt;&gt;&gt;&gt;&gt; std::list&lt;std::unique_ptr&lt;_Ty,std::default_delete&lt;_Ty&gt;&gt;,std::allocator&lt;std::unique_ptr&lt;_Ty,std::default_delete&lt;_Ty&gt;&gt;&gt;&gt;::insert&lt;std::_List_const_iterator&lt;std::_List_val&lt;std::_List_simple_types&lt;std::unique_ptr&lt;_Ty,std::default_delete&lt;_Ty&gt;&gt;&gt;&gt;&gt;&gt;(std::_List_const_iterator&lt;std::_List_val&lt;std::_List_simple_types&lt;std::unique_ptr&lt;_Ty,std::default_delete&lt;_Ty&gt;&gt;&gt;&gt;&gt;,_Iter,_Iter)' being compiled
          with
          [
              _Ty=int,
              _Iter=std::_List_const_iterator&lt;std::_List_val&lt;std::_List_simple_types&lt;std::unique_ptr&lt;int,std::default_delete&lt;int&gt;&gt;&gt;&gt;&gt;
          ]
  /opt/compiler-explorer/windows/19.10.25017/lib/native/include/list(939): note: see reference to function template instantiation 'std::_List_iterator&lt;std::_List_val&lt;std::_List_simple_types&lt;std::unique_ptr&lt;int,std::default_delete&lt;_Ty&gt;&gt;&gt;&gt;&gt; std::list&lt;std::unique_ptr&lt;_Ty,std::default_delete&lt;_Ty&gt;&gt;,std::allocator&lt;std::unique_ptr&lt;_Ty,std::default_delete&lt;_Ty&gt;&gt;&gt;&gt;::insert&lt;std::_List_const_iterator&lt;std::_List_val&lt;std::_List_simple_types&lt;std::unique_ptr&lt;_Ty,std::default_delete&lt;_Ty&gt;&gt;&gt;&gt;&gt;&gt;(std::_List_const_iterator&lt;std::_List_val&lt;std::_List_simple_types&lt;std::unique_ptr&lt;_Ty,std::default_delete&lt;_Ty&gt;&gt;&gt;&gt;&gt;,_Iter,_Iter)' being compiled
          with
          [
              _Ty=int,
              _Iter=std::_List_const_iterator&lt;std::_List_val&lt;std::_List_simple_types&lt;std::unique_ptr&lt;int,std::default_delete&lt;int&gt;&gt;&gt;&gt;&gt;
          ]
  /opt/compiler-explorer/windows/19.10.25017/lib/native/include/list(935): note: while compiling class template member function 'std::list&lt;std::unique_ptr&lt;int,std::default_delete&lt;_Ty&gt;&gt;,std::allocator&lt;std::unique_ptr&lt;_Ty,std::default_delete&lt;_Ty&gt;&gt;&gt;&gt;::list(const std::list&lt;std::unique_ptr&lt;_Ty,std::default_delete&lt;_Ty&gt;&gt;,std::allocator&lt;std::unique_ptr&lt;_Ty,std::default_delete&lt;_Ty&gt;&gt;&gt;&gt; &amp;)'
          with
          [
              _Ty=int
          ]
  /opt/compiler-explorer/windows/19.10.25017/lib/native/include/xmemory0(840): note: see reference to function template instantiation 'std::list&lt;std::unique_ptr&lt;int,std::default_delete&lt;_Ty&gt;&gt;,std::allocator&lt;std::unique_ptr&lt;_Ty,std::default_delete&lt;_Ty&gt;&gt;&gt;&gt;::list(const std::list&lt;std::unique_ptr&lt;_Ty,std::default_delete&lt;_Ty&gt;&gt;,std::allocator&lt;std::unique_ptr&lt;_Ty,std::default_delete&lt;_Ty&gt;&gt;&gt;&gt; &amp;)' being compiled
          with
          [
              _Ty=int
          ]
  &lt;source&gt;(10): note: see reference to class template instantiation 'std::list&lt;std::unique_ptr&lt;int,std::default_delete&lt;_Ty&gt;&gt;,std::allocator&lt;std::unique_ptr&lt;_Ty,std::default_delete&lt;_Ty&gt;&gt;&gt;&gt;' being compiled
          with
          [
              _Ty=int
          ]
  /opt/compiler-explorer/windows/19.10.25017/lib/native/include/memory(1857): note: 'std::unique_ptr&lt;int,std::default_delete&lt;_Ty&gt;&gt;::unique_ptr(const std::unique_ptr&lt;_Ty,std::default_delete&lt;_Ty&gt;&gt; &amp;)': function was explicitly deleted
          with
          [
              _Ty=int
          ]
  Microsoft (R) C/C++ Optimizing Compiler Version 19.10.25017 for x64
  Copyright (C) Microsoft Corporation.  All rights reserved.
  Compiler exited with result code 2
  </code></pre>