Understanding the process of initialization
<p>This is my attempt to understand how class initialization works. I'm not sure about everything, and that is why I'm asking this question. This is what I believe happens when we do the following:</p>

<pre><code>T t = u;
</code></pre>

<ol>
<li><p>Constructs an object of type <code>T</code> from <code>u</code>. This then becomes:</p>

<pre><code>T t = T(u);
</code></pre></li>
<li><p>Calls the copy-constructor:</p>

<pre><code>T t( T(u) );
</code></pre></li>
</ol>

<p>Okay the second is the part I'm not understanding. I read somewhere that <code>T t = u</code> is made into <code>T t(T(u))</code>. But if that is true why doesn't this print "copy-constructor":</p>

<pre><code>struct T
{
  template &lt;class U&gt;
  T(U) {
     std::cout &lt;&lt; "constructs an object of type T...\n";
  }

  T(T const &amp;)
  {
     std::cout &lt;&lt; "copy-constructor";
  }

  T&amp; operator=(T const &amp;)
  {
     std::cout &lt;&lt; "assignment operator"; return *this;
  }

  T() = default;
};

int main()
{
   T t(T(5));
}
</code></pre>

<p>Actually, all this does is print "constructs an object of type T". Why isn't the copy-constructor called here? <code>T(5)</code> can be made into an object of type <code>T const &amp;</code> which is passed into the constructor of <code>T</code> so shouldn't the appropriate constructor be called.</p>

<p>I'd really like some insight to this. I've been trying to understand this for a while.</p>
