title: Why is template constructor preferred to copy constructor?
body: <pre><code>#include &lt;iostream&gt;
  
  struct uct
  {
      uct() { std::cerr &lt;&lt; "default" &lt;&lt; std::endl; }
  
      uct(const uct &amp;) { std::cerr &lt;&lt; "copy" &lt;&lt; std::endl; }
      uct(      uct&amp;&amp;) { std::cerr &lt;&lt; "move" &lt;&lt; std::endl; }
  
      uct(const int  &amp;) { std::cerr &lt;&lt; "int" &lt;&lt; std::endl; }
      uct(      int &amp;&amp;) { std::cerr &lt;&lt; "int" &lt;&lt; std::endl; }
  
      template &lt;typename T&gt;
      uct(T &amp;&amp;) { std::cerr &lt;&lt; "template" &lt;&lt; std::endl; }
  };
  
  int main()
  {
      uct u1    ; // default
      uct u2( 5); // int
      uct u3(u1); // template, why?
  }
  </code></pre>
  
  <p><a href="https://coliru.stacked-crooked.com/a/7c9b0e27482dc82e" rel="noreferrer">coliru</a></p>
  
  <p>Template overload of the constructor fits to both declarations (<code>u2</code> and <code>u3</code>). But when <code>int</code> is passed to the constructor, a non-template overload is chosen. When the copy constructor is called, a template overload is chosen. As far as I know, a non-template function is always preferred to a template function during overload resolution. Why is the copy constructor handled differently?</p>