title: Memoryleak when using std::unique_ptr
body: <p>Im trying out unique_ptr to see how memory managment works in c++.</p>
  
  <p>Ding.h</p>
  
  <pre><code>#pragma once
  class Ding
  {
  public:
      int value;
      Ding();
      ~Ding();
  };
  </code></pre>
  
  <p>Ding.cpp</p>
  
  <pre><code>#include "stdafx.h"
  #include "Ding.h"
  #include &lt;iostream&gt;
  
  Ding::Ding()
  {
      value = 90000;
      std::cout &lt;&lt; "Constructor for ding called.";
  }
  
  
  Ding::~Ding()
  {
      std::cout &lt;&lt; "Destructor for ding called.";
  }
  </code></pre>
  
  <p>Main.cpp</p>
  
  <pre><code>#include "stdafx.h"
  #include &lt;memory&gt;
  #include "Ding.h"
  
  #define _CRTDBG_MAP_ALLOC
  #include &lt;stdlib.h&gt;
  #include &lt;crtdbg.h&gt;
  
  int main()
  {
      std::cout &lt;&lt; "starting." &lt;&lt; std::endl;
      std::vector&lt;std::unique_ptr&lt;Ding&gt;&gt; dingen;
      for (int i = 0; i &lt; 10; i++)
      {
           std::unique_ptr&lt;Ding&gt; toAdd(new Ding);
           dingen.push_back(std::move(toAdd));
      }
      std::cout &lt;&lt; "ending" &lt;&lt;std::endl;
  
      _CrtDumpMemoryLeaks();
      return 0;
  }
  </code></pre>
  
  <p>When I run this code I can see the memory errors in the debug output view:</p>
  
  <blockquote>
  <pre><code>Detected memory leaks!
  
  Dumping objects -&gt; {151} normal block at
  
  0x00000155B0798140, 104 bytes long.  Data: &lt;                &gt; 00 00 00
  00 00 00 00 00 00 00 00 00 00 00 00 00  {144} normal block at
  0x00000155B07A2300, 16 bytes long.  Data: &lt;  S             &gt; 08 FB 53
  D3 14 00 00 00 00 00 00 00 00 00 00 00  Object dump complete.
  </code></pre>
  </blockquote>
  
  <p>What creates these leaks?</p>
  
  <p>edit: as dasblinkenlight answer stated I need to use (new Ding), I accicdently removed that part when trying to find the leak. Added it to the question as it does not solve the memory leak but calls the constructor and destrctor for ding.</p>