title: C++ template deduction from lambda
body: <p>I have a function which takes two <code>std::function</code>s as arguments. The parameter of the second function has the same type as the result of the first.</p>
  
  <p>I wrote a function template like this:</p>
  
  <pre><code>template&lt;typename ResultType&gt;
  void examplFunction(std::function&lt;ResultType()&gt; func, std::function&lt;void(ResultType)&gt; func2) {
    auto x = func();
    func2(x);
  }
  </code></pre>
  
  <p>I can call it with:</p>
  
  <pre><code>void f() {
    examplFunction&lt;int&gt;([]() { return 1; },   //
                        [](int v) { std::cout &lt;&lt; "result is " &lt;&lt; v &lt;&lt; std::endl; });
  }
  </code></pre>
  
  <p>Is there a way to to get rid of the <code>&lt;int&gt;</code> at <code>examplFunction&lt;int&gt;</code> and let the compiler deduce the type of <code>ResultType</code>?</p>