title: Confusion with move constructors: unable to call move constructor
body: <p>I've been having difficulties understanding move constructors in C++. I have made a simple class with a default constructor, copy constructor, move constructor and destructor. Also, I have defined a function with two overloads, one accepts a reference to that class and one accepts an rvalue reference to that class. My test code is below.</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  
  class c {
  
  public:
  
      c() {
          std::cout &lt;&lt; "default constructor" &lt;&lt; std::endl;
      }
  
      c(const c&amp; s) {
          std::cout &lt;&lt; "copy constructor" &lt;&lt; std::endl;
      }
  
      c(c&amp;&amp; s) {
          std::cout &lt;&lt; "move constructor" &lt;&lt; std::endl;
      }
  
      ~c() {
          std::cout &lt;&lt; "destructor" &lt;&lt; std::endl;
      }
  
  };
  
  void f(c&amp; s) {
      std::cout &lt;&lt; "passed by reference" &lt;&lt; std::endl;
  }
  
  void f(c&amp;&amp; s) {
      std::cout &lt;&lt; "passed by rvalue reference" &lt;&lt; std::endl;
  }
  
  int main() {
  
      c s1; // line 1
      std::cout &lt;&lt; "\n";
      c s2(s1); // line 2
      std::cout &lt;&lt; "\n";
      c s3(c()); // line 3
  
      std::cout &lt;&lt; "\n";
  
      f(s1); // line 4
      std::cout &lt;&lt; "\n";
      f(c()); // line 5
  
      getchar();
      return 0;
  
  }
  </code></pre>
  
  <p>The output I'm getting is not what I was expecting. Below is the output I'm getting from this code.</p>
  
  <pre><code>default constructor
  
  copy constructor
  
  passed by reference
  
  default constructor
  passed by rvalue reference
  destructor
  </code></pre>
  
  <p>I can understand the outputs from all lines except <code>line 3</code>. On <code>line 3</code>, which is <code>c s3(c());</code>, <code>c()</code> is an rvalue so I'd expect that <code>s3</code> would be move constructed. But the output doesn't show that it is move constructed. On <code>line 5</code>, I'm doing the same thing and passing an <code>rvalue</code> to the function <code>f()</code> and it indeed calls the overload that accepts an <code>rvalue</code> reference. I'm very confused and would appreciate any information on this.</p>
  
  <p><strong>Edit:</strong> I am able to call the move constructor if I do <code>c s3(std::move(c()));</code> but am I not already passing an rvalue to s3? Why would I need <code>std::move</code>?</p>