title: Visual C++ 2010 : unordered_map and move constructor
body: <p>I have a structure named <code>Foo</code> which contains a <code>unique_ptr</code></p>
  
  <pre><code>struct Foo {
      std::unique_ptr&lt;Bar&gt; pointer;
  };
  </code></pre>
  
  <p>Now I'm trying to store instances of <code>Foo</code> in an <code>unordered_map</code></p>
  
  <pre><code>std::unordered_map&lt;int,Foo&gt; myMap;
  </code></pre>
  
  <p>Technically this should be possible, since maps do not require a copy constructor, only a move constructor.</p>
  
  <p>However, I can't insert an element in my map:</p>
  
  <pre><code>myMap.insert(std::make_pair(3, Foo()));
  </code></pre>
  
  <p>This line will generate the following error in Visual C++ 2010 (roughly translated by me, since my compiler is not in english):</p>
  
  <pre><code>error C2248: 'std::unique_ptr&lt;_Ty&gt;::unique_ptr' : unable to access private member declared in 'std::unique_ptr&lt;_Ty&gt;'  
  with
  [
               _Ty=Foo
  ]
  c:\Softwares\Visual Studio 10.0\VC\include\memory(2347) : see declaration of 'std::unique_ptr&lt;_Ty&gt;::unique_ptr'
  with
  [
               _Ty=Foo
  ]
  This diagnostic happened in the compiler-generated function 'Foo::Foo(const Foo&amp;)'
  </code></pre>
  
  <p>So for an unknown reason, the compiler tries to generate a copy constructor for <code>Foo</code> instead of a move constructor, and fails.</p>
  
  <p>I tried to replace <code>std::make_pair</code> with <code>std::pair&lt;int,something&gt;</code>, but can't find any <em><code>something</code></em> which works.</p>
  
  <hr>
  
  <p>EDIT : this works</p>
  
  <pre><code>struct Foo {
      Foo() {}
      Foo(Foo&amp;&amp; other) : pointer(std::move(other.pointer)) {}
      std::unique_ptr&lt;Bar&gt; pointer;
  };
  </code></pre>
  
  <p>But my real structure contains <strong>a lot</strong> of members, and I don't want to write all of them in the move constructor.</p>