Hi Folks,
Somewhat to my surprise this code, simply creating a filter_iterator, evaluates the predicate
until an element satisfying the predicate is found. This seems wrong to me. Shouldn't evaluation
of the predicate be delayed until the filter_iterator is dereferenced?
Thx, Rob.
#include <iostream>
#include <boost/range.hpp>
#include <boost/iterator/filter_iterator.hpp>
bool predicate( int i )
{
std::cout << "predicate(" << i << ")" << std::endl;
return true;
}
int main( )
{
int array[] = { 0, 1 };
boost::make_filter_iterator( predicate, boost::begin( array ), boost::end( array ) );
}
> [Run]
predicate(0)
>