title: Template placeholder not defined in return type of member, still works fine?
body: <p>In the following snippet, I omitted the template param placeholder in the return type of Assignment operator (operator=). In both the cases where I have specified the template parameter or not, the code just runs fine, just wondering why?</p>
  
  <p>Thanks</p>
  
  <pre><code>#include &lt;iostream&gt;
  using std::cout; using std::endl;
  
  class Ref
  {
      int _ref_counter;
  
  public:
      Ref() : _ref_counter(0)     {}
      void upRef() { _ref_counter++; }
  
      int downRef() { return --_ref_counter; }
  };
  
  template &lt;typename T1&gt; class SmartPointer
  {
      T1* _ptr;
      Ref *_ref;
  
  public:
      SmartPointer() : _ptr(0)
      {
          _ref = new Ref();
          _ref-&gt;upRef();
      }
  
      SmartPointer(T1* ptr): _ptr(ptr)
      {
          _ref = new Ref();
          _ref-&gt;upRef();
      }
  
      SmartPointer(const SmartPointer &amp;sp): _ptr(sp._ptr), _ref(sp._ref)
      {
      {
          _ref-&gt;upRef();
      }
  
  //      SmartPointer&lt;T1&gt;&amp; operator= (const SmartPointer &amp;sp)
      SmartPointer&amp; operator= (const SmartPointer &amp;sp)
      {
          //Always check self assignment
          if(this != &amp;sp)
          {
              //Lose the existing smartpointer info
              if(0 == _ref-&gt;downRef())
              {
                  delete _ptr;
                  delete _ref;
              }
  
              _ptr = sp._ptr;
              _ref = sp._ref;
              _ref-&gt;upRef();
          }
          return *this;
      }
  
      ~SmartPointer()
      {
          if(0 == _ref-&gt;downRef())
          {
              delete _ptr;
              delete _ref;
          }
      }
  
      T1&amp; operator* () { return *_ptr; }
  
      T1* operator-&gt; () { return _ptr; }
  };
  
  class Lock
  {
  public:
      void somefuntion()
      {
          cout &lt;&lt; "somefunction called ! " &lt;&lt; endl;
      }
  
      ~Lock()
      {
          cout &lt;&lt; "Destructor Lock called !" &lt;&lt; endl;
      }
  };
  
  int main()
  {
      SmartPointer&lt;Lock&gt; pMemLock(new Lock());
  
      pMemLock-&gt;somefuntion();
      {
          SmartPointer&lt;Lock&gt; pMemLock1(pMemLock);
      }
  
      SmartPointer&lt;Lock&gt; pMemLock2;
      pMemLock2 = pMemLock;
      pMemLock2-&gt;somefuntion();
  }
  </code></pre>