title: Function pointer and Template
body: <p>Why does the following code work? </p>
  
  <pre><code>class foo {
      public:
      template &lt;typename F&gt;
      int Map(F function) const {
         return function(2);
      }
  };
  int Double(int n) {
      return 2*n;
  }
  
  int main(){
      foo f;
      int n = f.Map(Double);
  }
  </code></pre>
  
  <p>My understanding is that the function accepting the function pointer must have format such as:</p>
  
  <p><code>void foo(int (*ptf)(int))</code> </p>
  
  <p>So the Map function should look like</p>
  
  <pre><code>int Map(int (*ptf)(int)){
      return (*ptf)(2);
  }
  </code></pre>
  
  <p>does the it somehow resolve the function at run-time or at compile-time through template?
  the above code was compiled and ran in vc++ 2010</p>