title: Move constructors and rvalue references
body: <pre><code>class Foo {
      int m_num;
  public:
      Foo() {}
  
      Foo(int&amp; n) {m_num = n;}
  
      Foo(int&amp;&amp; n) {m_num = n;}
  
      Foo(const Foo&amp; src) {m_num = src.m_num;}
  
      Foo(Foo&amp;&amp; src) {m_num = src.m_num;}
  
      Foo&amp; operator =(const Foo&amp; src) {
          m_num = src.m_num;
          return *this;
      }
  
      Foo&amp; operator =(Foo&amp;&amp; src) {// move
          m_num = src.m_num;
          return *this;
      }
  
      int&amp; operator =(const int&amp; src) {return m_num = src;}
  
      int&amp; operator =(int&amp;&amp; src) {return m_num = src;}
  };
  </code></pre>
  
  <p>Why is it that when I call <code>Foo f4(Foo(2));</code> it calls the <code>Foo(int&amp;&amp; n)</code> constructor instead of <code>Foo(Foo&amp;&amp; src)</code> constructor?
  Also why doesn't passing num which is an rvalue reference call move constructors?
  For example, <code>Foo f = num</code> does not call the move constructor.</p>
  
  <pre><code>int main() {
      int&amp;&amp; num = 5;
      /*int num{ 5 };*/ // initializer-list
      Foo f = num; // custom constructor
      f = num; // assignment operator
      Foo f2 = 6; // custom move constructor
      f2 = 10; // custom move assignment
      f2 = f; // assignment operator
      Foo f3(f); // custom constructor
      // f3(f2); // ERROR
      f3 = (f2); // assignment operator
  
      Foo f4(Foo(2));
  </code></pre>