title: Despite passing an rvalue, why isn't my move constructor getting called?
body: <p>I create a class string by defining default, copy &amp; move constructor. I try to create objects expecting each constructor to be invoked. As expected, the default &amp; copy constructor are invoked, but when I pass a rvalue(temporary object), I still see move constructor NOT being invoked.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;cstdlib&gt;
  #include &lt;cstring&gt;
  
  class string
  {
      char * data;
  public:
      string(const char * p = nullptr)
      {
          if(p == nullptr) return;
          std::cout &lt;&lt; "string(const char * p)" &lt;&lt; std::endl;
          size_t size = strlen(p) + 1;
          data = new char[size];
          memcpy(data, p, size);
      }
      ~string()
      {
          std::cout &lt;&lt; "~string() - " &lt;&lt; data &lt;&lt; std::endl;
          delete[] data;
      }
      string(const string &amp; that)
      {
          std::cout &lt;&lt; "string(const string &amp;)" &lt;&lt; std::endl;
          size_t size = strlen(that.data) + 1;
          data = new char[size];
          memcpy(data, that.data, size);
      }
      string(string &amp;&amp; that)
      {
          std::cout &lt;&lt; "string(string &amp;&amp; )" &lt;&lt; std::endl;
          data = that.data;
          that.data = nullptr;
      }
      void showData() { std::cout &lt;&lt; data &lt;&lt; std::endl; }
      string operator+(const string &amp; other)
      {
          size_t datasize = strlen(data);
          size_t othersize = strlen(other.data);
          size_t totalsize = datasize + othersize + 1;
          char * sData = new char[totalsize];
          memcpy(sData, data, strlen(data));
          memcpy(sData+datasize, other.data, totalsize-datasize);
          string s(sData);
          delete[] sData;
          return s;
  
      }
      string &amp; operator=(string that)
      {
          char * tmp = data;
          data = that.data;
          that.data = tmp;
          return *this;
      }
  };
  
  int main()
  {
      string s1{"stackoverflow"};  // s1
      string s2{s1};               // s2
      string s3{string("stack")+string("exchange")};  // s3
  }
  </code></pre>
  
  <p>At <strong>s1</strong>: <em>default constructor</em> is being called as expected.</p>
  
  <p>At <strong>s2</strong>: <em>copy constructor</em> is invoked, also as expected.</p>
  
  <p>At <strong>s3</strong>: I'm passing a temporary object. So, I expect <em>move constructor</em> be invoked, but <em>default constructor</em> being called.</p>
  
  <p>I'm unable to comprehend what I'm missing. Kindly help, thanks.</p>