<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 <vector>������������������������������������������������������������������������������������������������������������������������������ <br>#include <string><br>#include <iostream><br> #include <functional><br><br>#include <boost/iterator/filter_iterator.hpp><br>#include <boost/range/iterator_range.hpp><br><br><br>using namespace std;<br>using namespace boost;<br><br><br>int main()<br> {<br>��� vector<string> ss{"hello", "world"};<br>��� // function<bool (const string &)> fn = [](const string &s){return false;};<br>��� function<bool (const string &)> fn = [](const string &s){return s.size() > 3;};<br> ��� cout << fn("Hello") << endl; // (1)<br>��� cout << fn("world") << endl; // (2)<br>��� typedef<br>������� filter_iterator<function<bool (const string &)>, vector<string>::const_iterator><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 &a: r)<br>������� cout << a << 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<bool (const string &)> fn = [](const string &s){return false;};<br> ��� function<bool (const string &)> fn = [](const string &s){return s.size() > 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't figure out what I'm doing wrong, and would appreciate advice.<br><div><br>� Thanks,<br><br>� Ami<br></div></div>