title: Using templated member function pointer as template parameter
body: <p>I have this class:</p>
  
  <pre><code>#include &lt;assert.h&gt;
  
  template &lt;typename DeclaringType, typename HandlerType&gt;
  using SubscribeMethodType = void (DeclaringType::*)(HandlerType* handler);
  
  template &lt;typename DeclaringType&gt;
  using UnsubscribeMethodType = void (DeclaringType::*)();
  
  template &lt;SubscribeMethodType&lt;???_1, ???_2&gt; subscribeMethod, UnsubscribeMethodType&lt;???_1&gt; unsubscribeMethod&gt;
  class EventHandler
  {
  private:
      template &lt;typename T&gt;
      struct ExtractDeclaringAndHandlerTypes
      {
      };
  
      template &lt;typename DeclaringType, typename HandlerType&gt;
      struct ExtractDeclaringAndHandlerTypes&lt;void (DeclaringType::*)(HandlerType*)&gt;
      {
          typedef DeclaringType DeclaringType;
          typedef HandlerType HandlerType;
      };
  
      typedef typename ExtractDeclaringAndHandlerTypes&lt;decltype(subscribeMethod)&gt;::DeclaringType DeclaringType;
      typedef typename ExtractDeclaringAndHandlerTypes&lt;decltype(subscribeMethod)&gt;::HandlerType HandlerType;
  
  public:
      EventHandler() { }
      ~EventHandler()
      {
          Unsubscribe();
      }
  
      void Subscribe(DeclaringType* eventOwner, HandlerType* handler)
      {
          assert(!m_IsSubscribed);
  
          m_EventOwner = eventOwner;
          (eventOwner-&gt;*subscribeMethod)(handler);
          m_IsSubscribed = true;
      }
  
      void Unsubscribe()
      {
          if (m_IsSubscribed)
          {
              (m_EventOwner-&gt;*unsubscribeMethod)();
              m_IsSubscribed = false;
          }
      }
  
  private:
      DeclaringType* m_EventOwner;
      bool m_IsSubscribed;
  };
  </code></pre>
  
  <p>Example usage:</p>
  
  <pre><code>class IEventConsumer
  {
  };
  
  class ExampleEventOwner
  {
  public:
      void Subscribe(IEventConsumer* consumer) {}
      void Unsubscribe() {}
  };
  
  int main()
  {
      ExampleEventOwner owner;
      IEventConsumer consumer;
  
      EventHandler&lt;&amp;ExampleEventOwner::Subscribe, &amp;ExampleEventOwner::Unsubscribe&gt; handler;
      handler.Subscribe(&amp;owner, &amp;consumer);
      handler.Unsubscribe();
  
      return 0;
  }
  </code></pre>
  
  <p>Is it possible to specify something instead of "???_1" and "???_2" to allow them to be any type? The goal is to avoid the consumer of this class having to specify DeclaringType and HandlerType explicitly, since they can easily be inferred from subscribeMethod and unsubscribeMethod.</p>
  
  <p>Note: I cannot use C++17.</p>