title: std::function type and template instantiation
body: <p>I'm new to C++ and I'm learning about lambdas,functors and callables, and I know that there's a wrapper class, namely <code>std::function</code> that allows callables of different types to be stored and called (as long as the have the same call signature,or function type).</p>
  
  <p>Now, I understand that you can have function with function type parameters that are really just function pointer parameters as in :</p>
  
  <pre><code>void fun(int,int*(int,int&amp;));
  </code></pre>
  
  <p>which is nothing more than a function that takes an int and a function pointer to a function like <code>int *f(int,int&amp;)</code>,even if the language allows me to pass a function as an argument (with or without the ampersand).Infact, the function parameter list might as well be written as:</p>
  
  <pre><code>void fun(int,int*(*)(int,int&amp;));
  </code></pre>
  
  <p>Now,back to the <code>std::function</code> type</p>
  
  <p>I know that I can instantiate <code>std::function</code> with a function type and that allows any kind of callable to be passed to the wrapper. But, a function type is not a type I can use as a template type argument in any instantiation such as:</p>
  
  <pre><code>std::vector&lt;int(int)&gt; f_vec;
  </code></pre>
  
  <p>instead, I should make a vector of function pointers</p>
  
  <pre><code>std::vector&lt;int(*)(int)&gt; f_vec;
  </code></pre>
  
  <p>and that would allow me to insert pointers to function,but not functors or lambdas.</p>
  
  <p>So, my question is, how can I instantiate a template with a type argument like a function type?? what's happening under the hood in the library <code>std::function</code> type.I mean a function type seems to me a type I cannot use in templates?? pleas can you make things a little clearer,as I'm just beginning to learn these topics. Thanks</p>