<div dir="ltr"><div>� Hello,<br><br>� Using g++ 4.8.1 (g++ (Ubuntu/Linaro 4.8.1-10ubuntu8) 4.8.1) with boost 1.5.3, building the code below with <br>{{{<br>g++ -o example/filter.out -std=c++0x -Wall -g -rdynamic -I/usr/include/boost example/filter.cpp<br>
}}}<br><br>{{{<br>#include &lt;vector&gt;������������������������������������������������������������������������������������������������������������������������������ <br>#include &lt;string&gt;<br>#include &lt;iostream&gt;<br>
#include &lt;functional&gt;<br><br>#include &lt;boost/iterator/filter_iterator.hpp&gt;<br>#include &lt;boost/range/iterator_range.hpp&gt;<br><br><br>using namespace std;<br>using namespace boost;<br><br><br>int main()<br>
{<br>��� vector&lt;string&gt; ss{&quot;hello&quot;, &quot;world&quot;};<br>��� // function&lt;bool (const string &amp;)&gt; fn = [](const string &amp;s){return false;};<br>��� function&lt;bool (const string &amp;)&gt; fn = [](const string &amp;s){return s.size() &gt; 3;};<br>
��� cout &lt;&lt; fn(&quot;Hello&quot;) &lt;&lt; endl; // (1)<br>��� cout &lt;&lt; fn(&quot;world&quot;) &lt;&lt; endl; // (2)<br>��� typedef<br>������� filter_iterator&lt;function&lt;bool (const string &amp;)&gt;, vector&lt;string&gt;::const_iterator&gt;<br>
������� filter_it_t;<br>��� auto r = make_iterator_range(filter_it_t(fn, ss.begin()), filter_it_t(fn, ss.end()));<br>��� for(const string &amp;a: r)<br>������� cout &lt;&lt; a &lt;&lt; endl;<br><br>��� return 0;<br>}<br>}}}<br>
<br>yields an executable that crashes with <br>{{{<br>Segmentation fault (core dumped)<br>}}}<br><br>Exchanging the comment in the two lines<br>{{{<br>��� // function&lt;bool (const string &amp;)&gt; fn = [](const string &amp;s){return false;};<br>
��� function&lt;bool (const string &amp;)&gt; fn = [](const string &amp;s){return s.size() &gt; 3;};<br>}}}<br>(so that the first lambda is used) yields an executable that hangs.<br><br>� In either case, the application first prints the results of the lines marked (1) and (2).<br>
<br></div>� Can&#39;t figure out what I&#39;m doing wrong, and would appreciate advice.<br><div><br>� Thanks,<br><br>� Ami<br></div></div>