title: Is this a proper implementation of the Rule of Five (or Rule of Four and 1/2)?
body: <p>I am studying the Rule of Five and it's cousins (Rule of Four and 1/2, Copy and Swap idiom, Friend Swap Function).</p>
  <p>I implemented the Rule of Four and 1/2 on a test class. It compiles well. Is there any hidden mistake in my implementation?</p>
  <p>I  am particulary preoccupied about the unique_ptrs stored in the <em>m_unorederd_map</em> property that I moved in the copy constructor as they can't be copied. Is this the proper way to deal with unique_ptrs in classes?</p>
  <h3>someclass.h</h3>
  <pre class="lang-cpp prettyprint-override"><code>#ifndef SOMECLASS_H
  #define SOMECLASS_H
  
  #include &quot;someotherclass.h&quot;
  
  #include &lt;QString&gt;
  #include &lt;QStringList&gt;
  
  #include &lt;memory&gt;
  #include &lt;string&gt;
  #include &lt;unordered_map&gt;
  
  class SomeClass
  {
      QString m_qstring;
      std::unordered_map&lt;std::string, std::unique_ptr&lt;SomeOtherClass&gt;&gt; m_unordered_map;
      int m_int;
      std::string m_string;
      QStringList m_qstringlist;
  
  public:
      SomeClass() = default;
  
      // Rule of 5 (or Rule of 4 and 1/2)
      // From https://stackoverflow.com/questions/3279543/what-is-the-copy-and-swap-idiom#3279550
      ~SomeClass() = default;                               // Destructor
      SomeClass(SomeClass &amp;other);                          // Copy constructor
      SomeClass(SomeClass &amp;&amp;other);                         // Move constructor
      SomeClass &amp;operator=(SomeClass other);                // Copy/Move assignment operator
      friend void swap(SomeClass &amp;first, SomeClass &amp;second) // Friend swap function
      {
          using std::swap;
          first.m_qstring.swap(second.m_qstring);
          first.m_unordered_map.swap(second.m_unordered_map);
          swap(first.m_int, second.m_int);
          swap(first.m_string, second.m_string);
          first.m_qstringlist.swap(second.m_qstringlist);
      }
  };
  
  #endif // SOMECLASS_H
  </code></pre>
  <h3>someclass.cpp</h3>
  <pre class="lang-cpp prettyprint-override"><code>#include &quot;someclass.h&quot;
  
  // Copy constructor
  SomeClass::SomeClass(SomeClass &amp;other)
      : m_qstring(other.m_qstring),
        m_int(other.m_int),
        m_string(other.m_string),
        m_qstringlist(other.m_qstringlist)
  {
      // m_unordered_map holds unique_ptrs which can't be copied.
      // So we move it.
      m_unordered_map = std::move(other.m_unordered_map);
  }
  
  // Move constructor
  SomeClass::SomeClass(SomeClass &amp;&amp;other)
      : SomeClass()
  {
      swap(*this, other);
  }
  
  // Copy/Move assignment operator
  SomeClass &amp;SomeClass::operator=(SomeClass other)
  {
      swap(*this, other);
      return *this;
  }
  </code></pre>