title: Call a function with std::function as argument with a lambda
body: <p>The basis from my question I took from here:
  <a href="https://stackoverflow.com/questions/53326206/failure-to-deduce-template-argument-stdfunction-from-lambda-function">Failure to deduce template argument std::function from lambda function</a>
  The question in this thread is:
  Why this code can't pass the lambda to the function:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;functional&gt;
  
  template &lt;typename T&gt;
  void call(std::function&lt;void(T)&gt; f, T v)
  {
      f(v);
  }
  
  int main(int argc, char const *argv[])
  {
      auto foo = [](int i) {
          std::cout &lt;&lt; i &lt;&lt; std::endl;
      };
      call(foo, 1);
      return 0;
  }
  </code></pre>
  
  <p>The answer in this thread is, since a lambda isn't a <code>std::function</code>. But why is this code compiling:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;functional&gt;
  
  template &lt;typename T&gt;
  void call(std::function&lt;void(T)&gt; f, T v)
  {
      f(v);
  }
  
  int main(int argc, char const *argv[])
  {
      auto foo = [](int i) {
          std::cout &lt;&lt; i &lt;&lt; std::endl;
      };
      call({foo}, 1); // changed foo to {foo}
      return 0;
  }
  </code></pre>