title: C++ use of deleted function std::unique_ptr with Base class
body: <p>I have a vector or Game objects. I have to compile for c++11</p>
  
  <pre><code>std::vector&lt; std::unique_ptr&lt;Game&gt; &gt; games_;
  </code></pre>
  
  <p>Game is the base class, defined like this</p>
  
  <pre><code>class Game {
  
  public:
  
          Game(int id, const std::string&amp; name)
                  : id_(id), name_(name){}
  
          virtual ~Game(); 
  
          int play(int w);
          virtual void validate() = 0;
  
          int id_;
          std::string name_;
  
  };
  </code></pre>
  
  <p>The derived class just implements the validate() method.</p>
  
  <p>Now my manager class wants to post a "play game" to a thread pool. Done like this:</p>
  
  <pre><code>void Manager::playGames() {
  
  
          boost::asio::io_service ioService;
  
          std::unique_ptr&lt;boost::asio::io_service::work&gt; work( new boost::asio::io_service::work(ioService));
  
          boost::thread_group threadpool; //pool
          std::cout &lt;&lt; "will start for " &lt;&lt; playthreads_ &lt;&lt; " threads and " &lt;&lt; getTotalRequests() &lt;&lt; "total requests\n";
          for (std::size_t i = 0; i &lt; playthreads_; ++i)
                  threadpool.create_thread(boost::bind(&amp;boost::asio::io_service::run, &amp;ioService));
  
          for ( std::size_t i=0; i &lt; w_.size(); i++) {
  
                  ioService.post(boost::bind(&amp;Game::play, games_[i], 2));
  
          }    
  
          work.reset();
          threadpool.join_all();
          ioService.stop();
  
  }
  </code></pre>
  
  <p>The error is </p>
  
  <blockquote>
  <pre><code>/home/manager.cpp: In member function ‘void Manager::playGames()’:
  /home//manager.cpp:65:74: 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 = Game; _Dp = std::default_delete&lt;Game&gt;]’ 
   ioService.post(boost::bind(&amp;Game::play, games_[i], 2));
                                                                            ^
  In file included from /opt/5.2/include/c++/5.2.0/memory:81:0,
                   from /home/manager.hpp:5,
                   from /home/manager.cpp:1: /opt/5.2/include/c++/5.2.0/bits/unique_ptr.h:356:7: note: declared
  here
         unique_ptr(const unique_ptr&amp;) = delete;
  </code></pre>
  </blockquote>