title: Weird error of compilation of template specialization of Singleton
body: <p>I have a problem with templates that use a class and a function as parameters.
  The thing is that when only AAInterceptor is declared and defined, it works fine. When I add BBInterceptor, there is a compilator error that seems quite strange.</p>
  
  <p>Here's the code</p>
  
  <pre><code>template&lt; class T&gt;
  class Singleton
  {
  protected:
      static T* ms_Singleton;
      Singleton()
      {
          if(!ms_Singleton)ms_Singleton = new T;
      }
  public:
      static T&amp; getSingleton( void ){assert( 0); return *ms_Singleton; }
  };
  
  struct InterceptorData
  {
      unsigned int flag;
  
      InterceptorData():flag(0){}
  };
  
  template &lt;class C, void (C::*TMethod)(const InterceptorData*)&gt;
  class InterceptorManager : public Singleton&lt; InterceptorManager&lt;C,TMethod&gt; &gt;
  {
  
  };
  
  class AClass
  {
  public:
      virtual void Amethod(const InterceptorData* p_data = 0){};
  };
  
  class AAInterceptor : public InterceptorManager&lt;AClass, &amp;AClass::Amethod&gt;
  {
  public:
      static AAInterceptor&amp; getSingleton(void)
      {
          if (!ms_Singleton) new AAInterceptor();
          assert( ms_Singleton );  
          return ( *(static_cast&lt; AAInterceptor*&gt;(ms_Singleton)) );
      }
  };
  
  class BClass
  {
  public:
      virtual void Bmethod(const InterceptorData* p_data = 0){};
  };
  
  class BBInterceptor : public InterceptorManager&lt;BClass, &amp;BClass::Bmethod&gt;
  {
  public:
      static BBInterceptor&amp; getSingleton(void)
      {
          if (!ms_Singleton) new BBInterceptor();
          assert( ms_Singleton );  
          return ( *(static_cast&lt; BBInterceptor*&gt;(ms_Singleton)) );  //Here is the error of compilation
      }
  };
  
  int main(void)
  {
      AAInterceptor a;
      BBInterceptor b;
      return 0;
  }
  </code></pre>
  
  <p>It compiles fine with GCC (http://codepad.org/Bi6zbsmq), but not with MSVC2008.</p>
  
  <p>And here is the error in Visual Studio:</p>
  
  <pre><code>error:  " error C2440: 'static_cast' : cannot convert from 'InterceptorManager&lt;C,TMethod&gt; *' to 'BBInterceptor *' " 58
  with
  1&gt;        [
             1&gt;            C=BClass,
             1&gt;            TMethod=void AClass::`vcall'{0}'(const InterceptorData *)
             1&gt;        ]
  1&gt;        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
  </code></pre>
  
  <p>It seems that the compiler mixes different templates together, doesn't it?</p>
  
  <p>Thanx in advance for your help</p>