title: C++11 and the lack of polymorphic lambdas - why?
body: <p>I've been reviewing the draft version of the <a href="https://en.wikipedia.org/wiki/C++11" rel="nofollow noreferrer">C++11</a> standard. Specifically the section on <a href="https://en.wikipedia.org/wiki/Lambda_expression" rel="nofollow noreferrer">lambdas</a>, and I am confused as to the reasoning for not introducing polymorphic lambdas.</p>
  
  <p>For example, amongst the 100001 ways polymorphic lambdas could be used, I had hoped we could use code such as the following:</p>
  
  <pre><code>template&lt;typename Container&gt;
  void foo(Container c)
  {
      for_each(c.begin(), c.end(), [](T&amp; t) { ++t; });
  }
  </code></pre>
  
  <p>What were the reasons:</p>
  
  <ul>
  <li><p>Was it that the committee ran out of time?</p></li>
  <li><p>That polymorphic lambdas are too hard to implement?</p></li>
  <li><p>Or perhaps that they are seen as not being needed by the <a href="https://en.wikipedia.org/wiki/The_powers_that_be_%28phrase%29" rel="nofollow noreferrer">PTB</a>?</p></li>
  </ul>
  
  <p>Note: Please remember the example above is not the only one, and it is only provided as a guide to the types of code. Answers that solely concentrate on providing a workaround for the above piece of code will not be considered as valid!</p>
  
  <p>Related sources:</p>
  
  <ul>
  <li><em><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1968.pdf" rel="nofollow noreferrer">Lambda expressions and closures for C++</a></em> (document number N1968=06-0038)</li>
  <li><em><a href="https://stackoverflow.com/questions/3575901">Can lambda functions be templated?</a></em></li>
  </ul>