title: How to make variadic template class method take function pointer as argument with type derived from function template?
body: <p>Sorry the title is a mouthful. I'm working on an array class similar to the one discussed <a href="https://stackoverflow.com/questions/26766617">here</a>. I want to define a "map" function that takes a user-defined function and applies it to each element of the array. For the purposes of type-checking, I'd like to define it such that the user-specified function <strong>must</strong> take the same number of arguments as are passed to the map function, so that</p>
  
  <pre><code>double f(double a, double b) { return a + b; }
  Array&lt;double,2&gt; x, y, z; x.map(f, y, z);
  </code></pre>
  
  <p>will compile but</p>
  
  <pre><code>double g(double a, double b, double c) { return a + b + c; }
  Array&lt;double,2&gt; x, y, z;. x.map(g, y, z);
  </code></pre>
  
  <p>won't, becuase <code>g</code> takes the wrong number of arguments based on what was passed to the map function.</p>
  
  <p>I've tried a syntax like:</p>
  
  <pre><code>template&lt;typename T, size_t ... Ns&gt; class Array
  {
      template&lt;class ... Args&gt; inline const Array&lt;T, Ns...&gt;
          map(T (*fn)(decltype(Args, double)...), Args...)
      {
          // doesn't compile
      }
  }
  </code></pre>
  
  <p>I think this is close, but obviously wrong, since it doesn't compile. I'd be grateful to learn the correct syntax for an operation like this.</p>