|
Boost Users : |
Subject: Re: [Boost-users] New-style for on an iterator-range of filter_iterator of strings crashes/hangs
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2013-11-23 18:56:12
AMDG
On 11/23/2013 11:12 AM, Ami Tavory wrote:
> <snip>
> typedef
> filter_iterator<function<bool (const string &)>,
> vector<string>::const_iterator>
> filter_it_t;
> auto r = make_iterator_range(filter_it_t(fn, ss.begin()),
> filter_it_t(fn, ss.end()));
> <snip>
>
> yields an executable that crashes with
> {{{
> Segmentation fault (core dumped)
> }}}
>
> <snip>
>
You're not constructing the filter_iterators correctly.
>From the documentation:
filter_iterator(Predicate f, Iterator x, Iterator end = Iterator());
Effects:
Constructs a filter_iterator where m_iter is either
the first position in the range [x,end) such that
f(*m_iter) == true or else``m_iter == end``. The
member m_pred is constructed from f and m_end from end.
You need to pass the end iterator as well. (Or use
the Boost.Range version)
In Christ,
Steven Watanabe
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net