title: Copy constructor for templates
body: <p>Copy constructor is failing in the following code. I have clipped the code for clarity</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;stdio.h&gt;
  #include &lt;assert.h&gt;
  
  namespace my {
      template &lt;class T&gt;
      class Sptr {
      private:
          //some kind of pointer
              //one to current obj
          T* obj;
  .
  .
  .
      public:
  .
  .
  .
  
          Sptr(const Sptr &amp;);
  
          template &lt;typename U&gt; 
          Sptr(const Sptr&lt;U&gt; &amp;);
  
  .
  .
  .
  };//Class ends
  
      template &lt;typename T&gt;
      template &lt;typename U&gt; 
      Sptr&lt;T&gt;::Sptr(U* u) {
          //do something
      }
  
      template &lt;typename T&gt;
      Sptr&lt;T&gt;::Sptr(const Sptr&lt;T&gt; &amp;copyObj) {
          //do copy constructor stuff
      }
  .
  .
  .
  }
  
  using namespace std;
  using namespace my;
  /* Basic Tests 1 ================================================================================ */
  size_t AllocatedSpace;
  
  class Base1 {
      protected:
          Base1() : derived_destructor_called(false) {
              printf("Base1::Base1()\n");
          }
      private:
          Base1(const Base1 &amp;); // Disallow.
          Base1 &amp;operator=(const Base1 &amp;); // Disallow.
      public:
          virtual ~Base1() {
              printf("Base1::~Base1()\n");
              assert(derived_destructor_called);
          }
      protected:
          bool derived_destructor_called;
  };
  
  class Derived : public Base1 {
          friend void basic_tests_1();
      private:
          Derived() {}
          Derived(const Derived &amp;); // Disallow.
          Derived &amp;operator=(const Derived &amp;); // Disallow.
      public:
          ~Derived() {
              printf("Derived::~Derived()\n");
              derived_destructor_called = true;
          }
          int value;
  };
  </code></pre>
  
  <p>This test code line produces error <code>Sptr&lt;Base1&gt; sp3(sp);</code></p>
  
  <pre><code>void basic_tests_1() {
  
  
      //size_t base = AllocatedSpace;
  
      // Test deleting through original class.
      {
          // Base1 assigned from Sptr&lt;Derived&gt;.
          {
              Sptr&lt;Base1&gt; sp2;
              {
                  Sptr&lt;Derived&gt; sp(new Derived);
                  // Test template copy constructor.
                  Sptr&lt;Base1&gt; sp3(sp);
                  sp2 = sp;
                  sp2 = sp2;
              }
          }
      }
  }
  </code></pre>
  
  <p>Error:</p>
  
  <pre><code>/tmp/ccKrn1xG.o: In function `basic_tests_1()':
  Sptr.cpp:(.text+0x81): undefined reference to `my::Sptr&lt;Base1&gt;::Sptr&lt;Derived&gt;(my::Sptr&lt;Derived&gt; const&amp;)'
  collect2: error: ld returned 1 exit status
  </code></pre>