title: Function type not a valid type for a template non-type parameter?
body: <p>OpenGL defines C functions to manage resources. I wrote a simple wrapper to handle them in the RAII way. Function pairs are like <code>unsigned glCreateProgram()</code> and <code>void glDeleteProgram(unsigned program)</code>. However, there're function pairs which work on arrays of resources like <code>void glGenBuffers(size_t n, unsigned* buffers)</code> and <code>void glDeleteBuffers(size_t n, const unsigned* buffers);</code>. For the former I wrote a simple class to do the job, and for the latter I wrote another class which handles arrays. However, I noticed that at times I just use only one buffer or texture, where I don't have to incur the expense of a vector, I thought I'll specialize the class destructor if the release function takes a size parameterr in the beginning BUT...</p>
  
  <pre><code>template &lt;typename T_res,
            typename T_release_func,
            T_release_func func&gt;
  struct GL_resource
  {
      GL_resource(T_res name_) : name{name_}
      {
      }
  
      ~GL_resource()
      {
          func(name);
      }
  
  private:
      T_res name;
  };
  
  template &lt;typename T_res, typename FT, FT func, typename RT, typename DT&gt;
  struct GL_resource&lt;T_res, RT (size_t, DT*), func&gt;
  {
      ~GL_resource()
      {
          func(1, name);
      }
  };   
  </code></pre>
  
  <p>for the above SSCCE g++ barks:</p>
  
  <blockquote>
    <p>error: 'RT(unsigned int, DT*)' is not a valid type for a template non-type parameter struct GL_resource</p>
  </blockquote>
  
  <p>I then wrote a dummy function <code>void release(size_t, int*) {}</code> and rewrote the specilization as</p>
  
  <pre><code>template &lt;typename T_res, typename FT, FT func&gt;
  struct GL_resource&lt;T_res, decltype(release), release&gt;
  {
      ~GL_resource()
      {
          func(1, name);
      }
  };
  </code></pre>
  
  <p>This time I got:</p>
  
  <blockquote>
    <p>error: 'void(unsigned int, int*)' is not a valid type for a template non-type parameter struct GL_resource.</p>
  </blockquote>
  
  <p>Can someone explain why?</p>