title: error C2908: explicit specialization; '' has already been instantiated
body: <p>I have a simple template singleton class , I simplified if to keep is simple to read ( removed safeguard , asserts, etc.. it's not the subject of the question )</p>
  
  <pre><code>template&lt; class  T&gt; T* Create();
  
  template &lt;class T&gt;
  class CSingleton
  {
      public:
      static  T*      CreateInstance() { return m_instance = Create&lt;T&gt;(); }
      static  void    DestroyInstance() { delete m_instance;}
  
      protected:
      static T* m_instance;
  };
  </code></pre>
  
  <p>As you can see I use a global function T* Create() to new the pointer as my class could be an abstract class. so if instead I define CreateInstance like this :</p>
  
  <pre><code>static  T*      CreateInstance() { return m_instance = new T; }
  </code></pre>
  
  <p>It will generate an error that I can't instantiate an abstract class.</p>
  
  <p>So here a very simple exemple that generate the error ,
  The class :</p>
  
  <pre><code>class MyClass : public CSingleton&lt;MyClass&gt;
  {
  };
  </code></pre>
  
  <p>and the definition of the global function in my cpp</p>
  
  <pre><code>template&lt; &gt; MyClass* Create&lt; MyClass &gt;()
  {
      return nullptr;// just for the compilation demonstration
  }
  </code></pre>
  
  <p>If I dont define this , the linker will output error that it can't find Create(), If I define the function, I get this error :</p>
  
  <pre><code>error C2908:  explicit specialization; 'T *Create&lt;T&gt;(void)' has already been instantiated
  error C2908:         with
  error C2908:         [
  error C2908:             T=MyClass
  error C2908:         ]
  </code></pre>
  
  <p>I'm stuck for 2 hours on this problem, I can't find a solution, i googled and search on StackOverflow, coudln't find a similar problem and solution.</p>
  
  <p>Cheers,
  Seb</p>