Boost C++ Libraries: Ticket #8608: Default lambda expression with mpl::equal https://svn.boost.org/trac10/ticket/8608 <p> Summary of the original message posted on the mailing list: </p> <hr /> <p> Some higher order algorithms in the MPL have a default for the lambda expression they accept. A good example is <code>boost::mpl::equal</code>: </p> <pre class="wiki"> template &lt;typename S1, typename S2, typename Pred = is_same&lt;_, _&gt; &gt; struct equal; </pre><p> This works fine most of the time, but I was recently bitten by the following: </p> <pre class="wiki"> template &lt;typename VectorOfVectors, typename Vector&gt; struct find_vector : find_if&lt; VectorOfVectors, equal&lt;Vector, _1&gt; &gt; { }; typedef find_vector&lt; vector&lt; vector&lt;int, int&gt;, vector&lt;char, char&gt; &gt;, vector&lt;char, char&gt; &gt;::type ThisWillBreak; </pre><p> What happens here is that the <code>equal&lt;Vector, _1&gt;</code> expression inside <code>find_vector</code> really is <code>equal&lt;Vector, _1, is_same&lt;_1, _2&gt; &gt;</code> because of the default value for the predicate to <code>equal</code>. When the lambda is evaluated, the placholders inside the inner <code>is_same&lt;_1, _2&gt;</code> expression are replaced too, which yields unexpected results. </p> <hr /> <p> Original thread: <a class="ext-link" href="http://thread.gmane.org/gmane.comp.lib.boost.devel/241690"><span class="icon">​</span>http://thread.gmane.org/gmane.comp.lib.boost.devel/241690</a> </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/8608 Trac 1.4.3 Louis Dionne <ldionne.2@…> Wed, 22 May 2013 21:27:10 GMT attachment set https://svn.boost.org/trac10/ticket/8608 https://svn.boost.org/trac10/ticket/8608 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">default_lambda_args.diff</span> </li> </ul> <p> Test case, code fix and documentation change. </p> Ticket