title: Why is the move constructor called 2 times?
body: <p><strong>main.cpp</strong></p>
  <pre class="lang-cpp prettyprint-override"><code>#include &lt;iostream&gt;
  #include &lt;vector&gt; 
  #include &quot;Person.h&quot;
  using namespace std;
  
  int main()
  {
      vector&lt;Person&gt; test{};
  
      test.push_back (Person{ &quot;Chinese&quot;, 16 });
      test.push_back(Person{});
  
      return 0;
  }
  </code></pre>
  <p><strong>Person.h</strong></p>
  <pre><code>#pragma once
  #include &lt;iostream&gt;
  
  class Person
  {
  public:
      std::string* ethnicity;
      int age;
         
      Person(std::string ethnicity = &quot;Caucasian&quot;, int age = 15);
      ~Person();
      Person(const Person&amp; source);
      Person (Person&amp;&amp; source) noexcept;
  };
  </code></pre>
  <p><strong>Person.cpp</strong></p>
  <pre><code>#include &quot;Person.h&quot;
  
  Person::Person(std::string ethnicity, int age)
      : age(age)
  {
      this-&gt;ethnicity = new std::string; 
      *this-&gt;ethnicity = ethnicity;
  }
  
  Person::Person(const Person&amp; source)
      : Person(*source.ethnicity, source.age)
  {
      std::cout &lt;&lt; &quot;Copy constructor deep called!&quot; &lt;&lt; std::endl;
  }
  
  Person::Person(Person&amp;&amp; source) noexcept
      : ethnicity(source.ethnicity), age(source.age) 
  {
      std::cout &lt;&lt; &quot;Move constructor called!&quot; &lt;&lt; std::endl; 
      source.ethnicity = nullptr;
  }
  
  Person::~Person()
  {
      if (this-&gt;ethnicity != nullptr)
          std::cout &lt;&lt; &quot;Destructor called!&quot; &lt;&lt; std::endl;
      else
          std::cout &lt;&lt; &quot;Destructor called for nullptr!&quot; &lt;&lt; std::endl;
      delete ethnicity;
  }
  </code></pre>
  <p>Output</p>
  <p><a href="https://i.stack.imgur.com/KJPKK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KJPKK.png" alt="image" /></a></p>
  <p>From my understanding, only <strong>2 move constructors</strong> should be called. But why are <strong>3 move constructors</strong> called? The first <code>push_back()</code> should create a temporary object through the constructor, and then the move constructor will be called, then the destructor would be called for the temporary object. The process would be the same for the 2nd <code>push_back()</code>, so in total there would only be 2 move constructors getting called. But why are there 3?</p>