title: c++ move/copy/assignment with a unique_ptr<AbstractClass> member variable
body: <p>I have a problem very similar to </p>
  
  <p><a href="https://stackoverflow.com/questions/18521413/how-to-make-a-class-with-a-member-of-unique-ptr-work-with-stdmove-and-stdswa">How to make a class with a member of unique_ptr work with std::move and std::swap?</a></p>
  
  <p>and I am using VS2013 so I expect the following to work.</p>
  
  <pre><code>#include &lt;memory&gt;
  #include &lt;string&gt;
  
  class AbstractCamera{
  public:
      AbstractCamera(const std::string&amp; name) :_name(name){}
      virtual void method() = 0;
      std::string _name;
  };
  
  class CameraImpl : public AbstractCamera{
  public:
      CameraImpl() :AbstractCamera("CameraImpl"){}
      void method(){}
  };
  
  class RenderManager{
  public: 
      RenderManager():_currentCamera(std::move(std::make_unique&lt;CameraImpl&gt;())){}
  private:
      std::unique_ptr&lt;AbstractCamera&gt; _currentCamera;
  };
  
  class Engine{
  public: 
      Engine(){}
  private:
      RenderManager r;
  };
  
  int main(){
      Engine e;
      e = Engine(); // Causes error: C2280 call of deleted function
  }
  </code></pre>
  
  <blockquote>
    <p>path\engine.cpp(75): error C2280: 'std::unique_ptr> &amp;std::unique_ptr&lt;_Ty,std::default_delete&lt;_Ty>>::operator =(const std::unique_ptr&lt;_Ty,std::default_delete&lt;_Ty>> &amp;)' : attempting to reference a deleted function
             with
             [
                 _Ty=AbstractCamera
             ]
             other_path\memory(1487) : see declaration of 'std::unique_ptr>::operator ='
             with
             [
                 _Ty=AbstractCamera
             ]
             This diagnostic occurred in the compiler generated function 'RenderManager &amp;RenderManager::operator =(const RenderManager &amp;)'</p>
  </blockquote>
  
  <p>I do get that simple examples like</p>
  
  <pre><code>std::unique_ptr&lt;A&gt; a = std::make_unique&lt;A&gt;();
  std::unique_ptr&lt;A&gt; b = a;
  </code></pre>
  
  <p>are not allowed but my problem is the following code:</p>
  
  <pre><code>Engine e;
  e = Engine();
  </code></pre>
  
  <p>because the assignment operator of unique_ptr is deleted but how does this affect a class hierarchy like those of Engine->RenderManger->unique_ptr member.</p>
  
  <p>I do get, that <code>Engine e</code> uses the default constructor Engine() and <code>e = Engine()</code> calls the default constructor and the operator= of Engine to assign the temporary Engine object to e.</p>
  
  <p>My question therefore is: where does the code try to copy/assign unique_ptr and how do I resolve it?</p>
  
  <p>I tried to strip the original code down as much as possible but was not able to reproduce the error using a simpler example and ideone in form of a SSCCEE as I do not really understand what causes the problem, so sorry for that!</p>