title: Iterating through vector<unique_ptr<mytype>> using C++11 for() loops
body: <p>I've got the following batch of code:</p>
  
  <pre><code>std::vector&lt;std::unique_ptr&lt;AVLTree_GeeksforGeeks&gt;&gt; AVLArray(100000);
  
  /* Let's add some objects in the vector */
  AVLTree_GeeksforGeeks *avl = new AVLTree_GeeksforGeeks();
  avl-&gt;Insert[2]; avl-&gt;Insert[5]; AVL-&gt;Insert[0];
  unique_ptr&lt;AVLTree_GeeksforGeeks&gt; unique_p(avl);
  AVLArray[0] = move(unique_p);
  /* we do this for a number of other trees, let's say another 9...
  ...
  ...
  Now the vector has objects up until AVLTree[9] */
  
  /* Let's try iterating through its valid, filled positions */
  for(auto i : AVLTree )
  {
     cout &lt;&lt; "Hey there!\n";    //This loop should print 10 "Hey there"s.
  }
  </code></pre>
  
  <p><strong>Ruh roh.</strong> Compilation error at the last part, in the for() loop.</p>
  
  <pre><code>\DataStructures2013_2014\main.cpp||In function 'int main()':|
  \DataStructures2013_2014\main.cpp|158|error: use of deleted function 'std::unique_ptr&lt;_Tp, _Dp&gt;::unique_ptr(const std::unique_ptr&lt;_Tp, _Dp&gt;&amp;) [with _Tp = AVLTree_GeeksforGeeks; _Dp = std::default_delete&lt;AVLTree_GeeksforGeeks&gt;; std::unique_ptr&lt;_Tp, _Dp&gt; = std::unique_ptr&lt;AVLTree_GeeksforGeeks&gt;]'|
  e:\codeblocks\mingw\bin\..\lib\gcc\mingw32\4.7.1\include\c++\bits\unique_ptr.h|256|error: declared here|
  ||=== Build finished: 2 errors, 0 warnings (0 minutes, 0 seconds) ===|
  </code></pre>
  
  <p>Any ideas on what I am doing wrong?</p>