title: Correct way to write move constructor with unique_ptr member (crash)
body: <p>The following code will crash under Visual Studio 2013</p>
  
  <p>I'm wondering why : what's the correct way to write a move constructor in such a case ?
  Removing the move constructor solves the problem.
  Is it a bug of VC++ or is this code wrong ?</p>
  
  <p>What would be different in the default definition of the move constructor that makes this code not crash whereas my own definition does ?</p>
  
  <pre><code>#include &lt;memory&gt;
  #include &lt;vector&gt;
  
  class A
  {};
  
  class Foo
  {
  public:
      Foo(std::unique_ptr&lt;A&gt; ref) : mRef(std::move(ref)) {}
      Foo(Foo&amp;&amp; other) : mRef(std::move(other.mRef)) {}
  
      Foo(const Foo&amp; other) {}
      Foo&amp; operator=(const Foo&amp; other) { return *this; }
  
  protected:
      std::unique_ptr&lt;A&gt; mRef;
  };
  
  int main(int argc, char *argv[])
  {
      std::vector&lt;Foo&gt;({ Foo(std::make_unique&lt;A&gt;()), Foo(std::make_unique&lt;A&gt;()) });
      // Crash : Debug Assertion Failed !
      // Expression : _BLOCK_TYPE_IS_VALID(pHead-&gt;nBlockUse)
  }
  </code></pre>
  
  <p>It might be somehow related to this, right ?</p>
  
  <p><a href="https://stackoverflow.com/questions/20165166/double-delete-in-initializer-list-vs-2013">Double delete in initializer_list vs 2013</a></p>
  
  <p>Here is the actual code with fleshed out copy constructor and assignment, but the bug is exactly the same</p>
  
  <pre><code>class A
  {
  public:
       std::unique_ptr&lt;A&gt; clone() { return std::make_unique&lt;A&gt;(*this); }
  };
  
  class Foo
  {
  public:
      Foo(std::unique_ptr&lt;A&gt; ref) : mRef(std::move(ref)) {}
      Foo(Foo&amp;&amp; other) : mRef(std::move(other.mRef)) {}
  
      Foo(const Foo&amp; other) : mRef(other.mRef-&gt;clone()) {}
      Foo&amp; operator=(const Foo&amp; other) { mRef = other.mRef-&gt;clone(); return *this; }
  
  protected:
      std::unique_ptr&lt;A&gt; mRef;
  };
  </code></pre>