title: Why does C++ allow you to move classes containing objects with deleted move operations?
body: <p>Why am I allowed to use <code>std::move</code> on a class which contains fields of a type with deleted move semantics (case 1), but am not allowed to use it on an instance of such a class (case 2)?</p>
  
  <p>I understand case 2. I have explicitly deleted the move constructor, so I get an error if I try to move it. But I would expect that this would also be the case in case 1, where such class is also being moved.</p>
  
  <pre><code>class TestNonMovable {
    std::string ss;
   public:
    TestNonMovable(){}
    TestNonMovable(const TestNonMovable&amp;) {}
    TestNonMovable(TestNonMovable&amp;&amp;) = delete;
  };
  
  class SomeClass {
    TestNonMovable tnm;
  };
  
  int main() {    
      // case1: This compiles, my understanding is that for SomeClass::tnm compiler will use copy constrctor
      SomeClass sc1;
      SomeClass sc2 = std::move(sc1);
  
      // case2: This does not compile, move constructor is explicitly deleted, compiler will not try using copy constructor
      TestNonMovable tnm;
      TestNonMovable tnm2 = std::move(tnm); //error: use of deleted function 'TestNonMovable::TestNonMovable(TestNonMovable&amp;&amp;)'
  }
  </code></pre>