title: Linked list Move constructor
body: <p>I am trying to write a move constructor for a double linked list, but its not working. Can someone help me find what I am doing wrong? </p>
  
  <p>Here is my class:</p>
  
  <pre><code>class SortedList {
      struct Node {
          T data_;
          Node* next_;
          Node* prev_;
          Node(const T&amp; data = T{}, Node* nx = nullptr, Node* pr = nullptr) {
              data_ = data;
              next_ = nx;
              prev_ = pr;
          }
      };
  
      Node* front_;
      Node* back_;
      int sizelist;
  }
  </code></pre>
  
  <p>And here is my move constructor:</p>
  
  <pre><code>SortedList&lt;T&gt;::SortedList(SortedList&amp;&amp; rhs) {
      if (&amp;rhs != this) {
          sizelist = rhs.sizelist;
          front_ = rhs.front_;
          back_ = rhs.back_;  
  
          Node* head = rhs.front_;    
          Node* headNext =rhs.front_-&gt;next_;      
          for (int i = 0; i &lt; rhs.sizelist-1; i++) {
              head = nullptr;
              head = headNext;            
              headNext = headNext-&gt;next_;         
          }
          rhs.sizelist = 0;
      }
  }
  </code></pre>