title: C++ force instantiation of a template constructor of a template class
body: <p>Say I have a template class</p>
  
  <pre><code>template&lt;typename T&gt;
  class Foo {
      template&lt;typename U&gt;
          Foo(const Foo&lt;U&gt; &amp;foo) {
              ...
          }
  }
  </code></pre>
  
  <p>Obviously, <code>Foo&lt;T&gt;(const Foo&lt;T&gt;&amp;)</code> is an instance of that template member, but for some reason C++ chooses to use the implicit copy constructor instead of instantiating this copy constructor from the template.</p>
  
  <p>Is there a way to force the copy constructor to be instantiated from the template?</p>
  
  <p>Usually, something like</p>
  
  <pre><code>template&lt;&gt; template&lt;&gt; Foo&lt;int&gt;::Foo(const Foo&lt;int&gt;&amp;);
  </code></pre>
  
  <p>would work if I want a <em>specific</em> instance, but I want every <code>Foo&lt;T&gt;</code> that gets instantiated to also have <code>Foo(const Foo&lt;T&gt;&amp;)</code> be instantiated as well.</p>
  
  <p>How can I achieve this?</p>
  
  <p>Without actually writing out <code>Foo::Foo(const Foo&amp;);</code> separately, using the same exact code, of course. That would be silly.</p>