title: Specialize a template to only take a typename of a class with template arguments
body: <p>Maybe to understand the problem it's best if I first show the code.</p>
  <pre><code>#include &lt;type_traits&gt;
  #include &lt;functional&gt;
  #include &lt;array&gt;
  
  template&lt;size_t MaxSubscribers_, typename T&gt;
  struct Event
  {
      using Arg_T = T;
      static constexpr size_t MaxSubscribers = MaxSubscribers_;
  };
  
  class EventManager
  {
  public: //TODO: needs to be made private
      template&lt;size_t MaxSubscribers, typename T&gt;
      struct subscriberMap
      {
          template&lt;typename E, typename Valid = void&gt;
          struct events
          {
          };
  
          template&lt;typename E&gt;
          struct events&lt;E, typename std::enable_if&lt;std::is_base_of&lt;Event&lt;MaxSubscribers, T&gt;, E&gt;::value&gt;::type&gt;
          {
              static std::array&lt;std::function&lt;void(typename E::Arg_T)&gt;, E::MaxSubscribers&gt; list;
          };
      };
  
  public:
      template&lt;typename E, size_t MaxSubscribers, typename Arg_T &gt;
      void subscribe(std::function&lt;void(Arg_T)&gt; callback) = delete;
  
      template&lt;template&lt;size_t, typename&gt; typename E, size_t MaxSubscribers, typename Arg_T&gt;
      void subscribe&lt;E&lt;MaxSubscribers, Arg_T&gt;, MaxSubscribers, Arg_T&gt;(std::function&lt;void(Arg_T)&gt; callback) // Error non-type partial specialization 'subscribe&lt;E&lt;MaxSubscribers, Arg_T&gt;, MaxSubscribers, Arg_T&gt;' is not allowed
      {
          subscriberMap&lt;MaxSubscribers, Arg_T&gt;::events&lt;E&gt;::list[0] = callabck;
      }
  };
  
  template&lt;size_t MaxSubscribers, typename T&gt;
  template&lt;typename E&gt;
  std::array&lt;std::function&lt;void(typename E::Arg_T)&gt;, E::MaxSubscribers&gt;
  EventManager::subscriberMap&lt;MaxSubscribers, T&gt;::events&lt;E, typename std::enable_if&lt;std::is_base_of&lt;Event&lt;MaxSubscribers, T&gt;, E&gt;::value&gt;::type&gt;::list{};
  </code></pre>
  <p>I've got the data structure <code>Event</code> which is used to &quot;index&quot; <code>subscriberMap</code> and then add functions to <code>list</code>. I want to check if the template parameter <code>E</code> is an <code>Event</code> or any child class of it only when this is true <code>list</code> is a member of <code>events</code> and the program compiles. If <code>E</code> is not an Event the program should not compile.</p>
  <p>To add a function to <code>list</code> you call the function <code>subscribe</code>. <code>subscribe</code> needs to know what the maximal number of subscribers <code>MaxSubscribers</code> and the type of the argument, <code>Arg_T</code>,that will be passed to all functions in <code>list</code>. This information is also in the Event that is passed as the template parameter <code>E</code>.</p>
  <p>The problem is that I have to have access to the members of <code>E</code>, my approach doesn't work because of the error <code>non-type partial specialization 'subscribe&lt;E&lt;MaxSubscribers, Arg_T&gt;, MaxSubscribers, Arg_T&gt;' is not allowed</code> and if I don't specialize the template of <code>subscribe</code> I can not access <code>list</code>.</p>
  <p>This has to be done with no heap allocation and no libraries except the headers that are already included.</p>
  <p><strong>EDIT</strong></p>
  <p>I actually found a way how to remove the <code>partial specialization</code> error.</p>
  <p>As <a href="https://stackoverflow.com/questions/8061456/c-function-template-partial-specialization?rq=1">this post</a> says, the thing I want to do with this function is not possible. So I decided to just use a struct to wrap the function.
  This looks like this:</p>
  <pre><code>template&lt;typename E, typename Valid=void&gt;
  struct Subscriptor
  {
  };
  
  template&lt;typename E&gt;
  struct Subscriptor&lt;E, typename std::enable_if&lt;std::is_base_of&lt;Event&lt;E::MaxSubscribers, typename E::Arg_T&gt;, E&gt;::value&gt;::type&gt;
  {
      void subscribe(std::function&lt;void(typename E::Arg_T)&gt; callback)
      {
          subscriberMap&lt;E::MaxSubscribers, typename E::Arg_T&gt;::events&lt;E&gt;::list[0] = callaback;
      }
  };
  </code></pre>
  <p>Unfortunately though the compiler still gives me an error that <code>list</code> has not been defined, which means the template is not specific enough to stop the error case.</p>